From a76b281eb8c75b2995417594f912908fcac7622e Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sat, 5 Jun 2021 12:39:58 +0300 Subject: [PATCH] Fix building with glibc from rosa2016.1 Removed patch fixed it in one place, but now the same fix is required in another place, make a more generic solution (borrow it from systemd) (XXX is mixing LGPL with Apache 2.0 OK here..?) The error was the following: ``` [16040/48909] CXX obj/mojo/core/impl_for_embedder/channel_linux.o FAILED: obj/mojo/core/impl_for_embedder/channel_linux.o /opt/llvm12/bin/clang++ -MMD -MF obj/mojo/core/impl_for_embedder/channel_linux.o.d -DMOJO_SYSTEM_IMPL_IMPLEMENTATION -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_OZONE=1 -DUSE_X11=1 -DOFFICIAL_BUILD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DNO_UNWIND_TABLES -D_GNU_SOURCE -DCR_CLANG_REVISION=\"llvmorg-13-init-6429-g0e92cbd6-2\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=8fa87946779682841e21e2da977eccfb6cb3bded -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -I../.. -Igen -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../third_party/abseil-cpp -I../../third_party/boringssl/src/include -I../../third_party/protobuf/src -Igen/protoc_out -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -fno-unwind-tables -fno-asynchronous-unwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -flto=thin -fsplit-lto-unit -fwhole-program-vtables -fcomplete-member-pointers -m64 -march=x86-64 -msse3 -no-canonical-prefixes -Wall -Wextra -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-psabi -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -Wno-max-tokens -fno-omit-frame-pointer -g0 -ftrivial-auto-var-init=pattern -fsanitize=cfi-vcall -fsanitize-blacklist=../../tools/cfi/ignores.txt -fsanitize=cfi-icall -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wshadow -O2 -fdata-sections -ffunction-sections -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DPROTOBUF_ALLOW_DEPRECATED=1 -std=c++14 -fno-trigraphs -Wno-trigraphs -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include -fvisibility-inlines-hidden -c ../../mojo/core/channel_linux.cc -o obj/mojo/core/impl_for_embedder/channel_linux.o ../../mojo/core/channel_linux.cc:109:29: error: use of undeclared identifier 'F_SEAL_SEAL' constexpr int kMemFDSeals = F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW; ^ ../../mojo/core/channel_linux.cc:109:43: error: use of undeclared identifier 'F_SEAL_SHRINK' constexpr int kMemFDSeals = F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW; ^ ../../mojo/core/channel_linux.cc:109:59: error: use of undeclared identifier 'F_SEAL_GROW' constexpr int kMemFDSeals = F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW; ^ ../../mojo/core/channel_linux.cc:153:23: error: use of undeclared identifier 'F_ADD_SEALS' if (fcntl(fd.get(), F_ADD_SEALS, kMemFDSeals) < 0) { ^ ../../mojo/core/channel_linux.cc:165:32: error: use of undeclared identifier 'F_GET_SEALS' if ((seals = fcntl(fd.get(), F_GET_SEALS)) < 0) { ^ 5 errors generated. ``` --- chromium-86.0.4240.80-fcntl-h.patch | 26 ------------ chromium-browser-stable.spec | 10 +++-- missing_fcntl.h | 62 +++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 29 deletions(-) delete mode 100644 chromium-86.0.4240.80-fcntl-h.patch create mode 100644 missing_fcntl.h diff --git a/chromium-86.0.4240.80-fcntl-h.patch b/chromium-86.0.4240.80-fcntl-h.patch deleted file mode 100644 index 085989c..0000000 --- a/chromium-86.0.4240.80-fcntl-h.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff -up chromium-86.0.4240.75/sandbox/policy/linux/bpf_gpu_policy_linux.cc.epel7-kcmp chromium-86.0.4240.75/sandbox/policy/linux/bpf_gpu_policy_linux.cc ---- chromium-86.0.4240.75/sandbox/policy/linux/bpf_gpu_policy_linux.cc.epel7-kcmp 2020-10-20 11:58:00.449812627 -0400 -+++ chromium-86.0.4240.75/sandbox/policy/linux/bpf_gpu_policy_linux.cc 2020-10-20 11:58:32.919071919 -0400 -@@ -22,6 +22,22 @@ - #include "sandbox/policy/linux/sandbox_linux.h" - #include "sandbox/policy/linux/sandbox_seccomp_bpf_linux.h" - -+#ifndef F_LINUX_SPECIFIC_BASE -+#define F_LINUX_SPECIFIC_BASE 1024 -+#endif -+#ifndef F_SEAL_SEAL -+#define F_SEAL_SEAL 0x0001 -+#endif -+#ifndef F_SEAL_SHRINK -+#define F_SEAL_SHRINK 0x0002 -+#endif -+#ifndef F_SEAL_GROW -+#define F_SEAL_GROW 0x0004 -+#endif -+#ifndef F_ADD_SEALS -+#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) -+#endif -+ - using sandbox::bpf_dsl::Allow; - using sandbox::bpf_dsl::Arg; - using sandbox::bpf_dsl::Error; diff --git a/chromium-browser-stable.spec b/chromium-browser-stable.spec index e2f039e..160e18a 100644 --- a/chromium-browser-stable.spec +++ b/chromium-browser-stable.spec @@ -92,6 +92,9 @@ Source10: %{name}.rpmlintrc Source11: rpmlint-wrapper.sh # Bring xcb-proto with us (might need more than python on EPEL?) Source20: https://www.x.org/releases/individual/proto/xcb-proto-%{xcb_version}.tar.xz +# From https://github.com/systemd/systemd/blob/main/src/basic/missing_fcntl.h +# to fix building on rosa2016.1 where glibc does not have /usr/include/bits/fcntl-linux.h +Source21: missing_fcntl.h Source30: master_preferences Source31: default_bookmarks.html Source32: chromium.default @@ -133,8 +136,6 @@ Patch600: chromium-buildname-60.0.3112.90.patch Patch601: chromium-62-include-cstdlib.patch # Add "ROSA" to the user agent string -# Fix build /sandbox/policy/linux/bpf_gpu_policy_linux.cc on rosa2016.1 -Patch637: chromium-86.0.4240.80-fcntl-h.patch Patch627: chromium-68.0.3440.106-rosa-user-agent.patch # Fix building third_party/wayland on rosa2016.1 Patch639: wayland-strndup.patch @@ -367,7 +368,6 @@ cp -f %{_gostsourcedir}/src/msspi/third_party/cprocsp/include/* third_party/bori %patch600 -p1 %patch601 -p1 %patch627 -p1 -%patch637 -p1 %patch639 -p1 %patch640 -p1 %patch643 -p1 @@ -595,6 +595,10 @@ export LDFLAGS="-Wl,--threads=1" %endif %endif +%if %{mdvver} < 201900 +grep -IrlE '#include([[:space:]])*' | xargs sed -i'' -E -e 's,#include([[:space:]])*,#include "%{SOURCE21}",' +%endif + out/Release/gn gen --script-executable=%{__python} --args='%{gn_config}' out/Release pushd out/Release diff --git a/missing_fcntl.h b/missing_fcntl.h new file mode 100644 index 0000000..3527f66 --- /dev/null +++ b/missing_fcntl.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* From systemd, commit db9ecf050165fd1033c6f81485917e229c4be537 */ + +#pragma once + +#include + +#ifndef F_LINUX_SPECIFIC_BASE +#define F_LINUX_SPECIFIC_BASE 1024 +#endif + +#ifndef F_SETPIPE_SZ +#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) +#endif + +#ifndef F_GETPIPE_SZ +#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) +#endif + +#ifndef F_ADD_SEALS +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) + +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ +#define F_SEAL_GROW 0x0004 /* prevent file from growing */ +#define F_SEAL_WRITE 0x0008 /* prevent writes */ +#endif + +#ifndef F_OFD_GETLK +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 +#endif + +#ifndef MAX_HANDLE_SZ +#define MAX_HANDLE_SZ 128 +#endif + +/* The precise definition of __O_TMPFILE is arch specific; use the + * values defined by the kernel (note: some are hexa, some are octal, + * duplicated as-is from the kernel definitions): + * - alpha, parisc, sparc: each has a specific value; + * - others: they use the "generic" value. + */ + +#ifndef __O_TMPFILE +#if defined(__alpha__) +#define __O_TMPFILE 0100000000 +#elif defined(__parisc__) || defined(__hppa__) +#define __O_TMPFILE 0400000000 +#elif defined(__sparc__) || defined(__sparc64__) +#define __O_TMPFILE 0x2000000 +#else +#define __O_TMPFILE 020000000 +#endif +#endif + +/* a horrid kludge trying to make sure that this will fail on old kernels */ +#ifndef O_TMPFILE +#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) +#endif