Moroshima / zotero-deb

4 stars 0 forks source link

在 debian trixie/sid 上复现 firefox esr 60.9 构建 #4

Open Moroshima opened 1 year ago

Moroshima commented 1 year ago

在 debian trixie/sid 上复现 firefox esr 60.9 构建并将相关内容整理成文档

Moroshima commented 1 year ago

将效法如上 debug glibc 特性变动导致的编译错误

 0:02.28 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp: In function ‘mozilla::Telemetry::ProcessedStack mozilla::Telemetry::GetStackAndModules(const std::vector<long unsigned int>&)’:
 0:02.28 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:74:30: error: ‘numeric_limits’ is not a member of ‘std’
 0:02.28    74 |                         std::numeric_limits<uint16_t>::max()};
 0:02.28       |                              ^~~~~~~~~~~~~~
 0:02.28 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:74:53: error: expected primary-expression before ‘>’ token
 0:02.28    74 |                         std::numeric_limits<uint16_t>::max()};
 0:02.28       |                                                     ^
 0:02.28 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:74:56: error: ‘::max’ has not been declared; did you mean ‘std::max’?
 0:02.28    74 |                         std::numeric_limits<uint16_t>::max()};
 0:02.28       |                                                        ^~~
 0:02.28       |                                                        std::max
 0:02.28 In file included from /usr/include/c++/12/algorithm:61,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/system_wrappers/algorithm:3,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/stl_wrappers/algorithm:44,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Span.h:33,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/nsTSubstring.h:16,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/nsAString.h:22,
 0:02.28                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/nsString.h:14,
 0:02.28                  from /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.h:11,
 0:02.29                  from /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:7:
 0:02.29 /usr/include/c++/12/bits/stl_algo.h:5756:5: note: ‘std::max’ declared here
 0:02.29  5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
 0:02.29       |     ^~~
 0:02.29 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:110:41: error: ‘numeric_limits’ is not a member of ‘std’
 0:02.29   110 |         rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.29       |                                         ^~~~~~~~~~~~~~
 0:02.29 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:110:65: error: expected primary-expression before ‘>’ token
 0:02.29   110 |         rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.31       |                                                                 ^
 0:02.31 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:110:68: error: ‘::max’ has not been declared; did you mean ‘std::max’?
 0:02.31   110 |         rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.31       |                                                                    ^~~
 0:02.31       |                                                                    std::max
 0:02.31 /usr/include/c++/12/bits/stl_algo.h:5756:5: note: ‘std::max’ declared here
 0:02.31  5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
 0:02.31       |     ^~~
 0:02.31 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:124:37: error: ‘numeric_limits’ is not a member of ‘std’
 0:02.31   124 |     rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.31       |                                     ^~~~~~~~~~~~~~
 0:02.31 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:124:61: error: expected primary-expression before ‘>’ token
 0:02.31   124 |     rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.31       |                                                             ^
 0:02.31 /home/moroshima/firefox-60.9.0/toolkit/components/telemetry/ProcessedStack.cpp:124:64: error: ‘::max’ has not been declared; did you mean ‘std::max’?
 0:02.31   124 |     rawStack[stackIndex].mPC = std::numeric_limits<uintptr_t>::max();
 0:02.31       |                                                                ^~~
 0:02.31       |                                                                std::max
 0:02.31 /usr/include/c++/12/bits/stl_algo.h:5756:5: note: ‘std::max’ declared here
 0:02.31  5756 |     max(initializer_list<_Tp> __l, _Compare __comp)
 0:02.31       |     ^~~
 0:02.36 In file included from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/Mutex.h:12,
 0:02.36                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/include/mozilla/StaticMutex.h:11,
 0:02.36                  from /home/moroshima/firefox-60.9.0/tools/profiler/core/platform.h:38,
 0:02.36                  from /home/moroshima/firefox-60.9.0/tools/profiler/core/shared-libraries-linux.cc:17:
Moroshima commented 1 year ago

https://stackoverflow.com/questions/71296302/numeric-limits-is-not-a-member-of-std

图片

看上去该问题是 gcc 导致的,下面尝试回退 gcc 版本至 gcc8.3.0

Moroshima commented 1 year ago

回退 gcc/g++ 成功规避 numeric_limits bug,但仍然存在 std max 未定义的问题

 0:02.16 /home/moroshima/firefox-60.9.0/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc:147:65
 error: no matching function for call to ‘max(int, long int)’
 0:02.16    static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);
 0:02.16                                                                  ^
 0:02.16 In file included from /usr/local/include/c++/8.3.0/algorithm:61,
 0:02.16                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/system_wrappers/algorithm:3,
 0:02.16                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/stl_wrappers/algorithm:44,
 0:02.16                  from /home/moroshima/firefox-60.9.0/toolkit/crashreporter/breakpad-client/linux/crash_generation/crash_generation_client.cc:36,
 0:02.16                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/breakpad-client/linux/Unified_cpp_linux0.cpp:2:
Moroshima commented 1 year ago

看上去又是 glibc 的问题

https://lore.kernel.org/all/20220116040525.3007767-1-james.hilliard1@gmail.com/ https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1959319

Moroshima commented 1 year ago

应用 archlinux 所提供的类似问题解决的 patch 后规避上条 bug

https://gitlab.archlinux.org/syo093c/chromium/-/blob/ed62a31300aadf22c608d9203875eb81a3bb3715/breakpad-fix-for-non-constant-SIGSTKSZ.patch

Moroshima commented 1 year ago

new bug needs to patch

 0:10.78 In file included from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/Unified_cpp_client0.cpp:38:
 0:10.78 /home/moroshima/firefox-60.9.0/toolkit/crashreporter/client/ping.cpp: In function ‘std::__cxx11::string CrashReporter::GenerateUUID()’:
 0:10.78 /home/moroshima/firefox-60.9.0/toolkit/crashreporter/client/ping.cpp:54:18: error: cannot convert ‘CrashReporter::UUID’ to ‘void*’
 0:10.78    arc4random_buf(id, sizeof(UUID));
 0:10.78                   ^~
 0:10.78 In file included from /usr/local/include/c++/8.3.0/cstdlib:75,
 0:10.78                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/system_wrappers/cstdlib:3,
 0:10.78                  from /usr/local/include/c++/8.3.0/ext/string_conversions.h:41,
 0:10.78                  from /usr/local/include/c++/8.3.0/bits/basic_string.h:6400,
 0:10.78                  from /usr/local/include/c++/8.3.0/string:52,
 0:10.78                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/system_wrappers/string:3,
 0:10.78                  from /home/moroshima/firefox-60.9.0/toolkit/crashreporter/client/crashreporter.h:14,
 0:10.78                  from /home/moroshima/firefox-60.9.0/toolkit/crashreporter/client/crashreporter.cpp:6,
 0:10.78                  from /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/Unified_cpp_client0.cpp:2:
Moroshima commented 1 year ago

this patch

https://hg.mozilla.org/integration/autoland/rev/a61813bd9f0a

from

https://bugzilla.mozilla.org/show_bug.cgi?id=1782988

Moroshima commented 1 year ago

new bug

 0:03.01 /home/moroshima/firefox-60.9.0/security/sandbox/linux/launch/SandboxLaunch.cpp: In function ‘pid_t mozilla::{anonymous}::DoClone(int, __jmp_buf_tag (*)[1])’:
 0:03.01 /home/moroshima/firefox-60.9.0/security/sandbox/linux/launch/SandboxLaunch.cpp:424:38: error: no matching function for call to ‘ArrayEnd(uint8_t [(<anonymous> + 1)])’
 0:03.01    void* stackPtr = ArrayEnd(miniStack);
 0:03.01                                       ^
heroxbd commented 1 year ago

现在 patch 有点多了,你把它们都放在了哪里管理?

Moroshima commented 1 year ago

现在 patch 有点多了,你把它们都放在了哪里管理?

我的计划是将编译全流程 glibc 导致的问题 debug 完成后统一集中在同一个目录中存放 patch。因为上面所使用的 patch 分别是针对不同 firefox 版本,甚至是针对 chromium 的 patch,不能直接应用于我们所尝试构建的 firefox 60.9esr。后续存放方式应该和 gentoo/gcc-patch 项目类似,使用序号标号+修复信息命名的方式进行集中管理,然后在构建脚本中逐一 patch 到 firefox 源码上。

Moroshima commented 1 year ago

我可能主要会把这个 issue 用于记录构建中所遇到的问题及相关解决方案,以保证后续可稳定复现问题或构建

FantasqueX commented 1 year ago

补充一些可能有用的文档,关于 debian 如何管理 patch

https://www.debian.org/doc/manuals/debmake-doc/ch05.en.html#patches

Moroshima commented 1 year ago

补充一些可能有用的文档,关于 debian 如何管理 patch

https://www.debian.org/doc/manuals/debmake-doc/ch05.en.html#patches

感谢

Moroshima commented 1 year ago

下面的 patch 可规避上一个 bug,但编译依然会 Error 如后

https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1983645 https://bugzilla.redhat.com/attachment.cgi?id=1803524&action=diff

Only in firefox-90.0/js/xpconnect/src: XPCJSContext.cpp.firefox-glibc-dynstack
diff -ur firefox-90.0.orig/security/sandbox/linux/launch/SandboxLaunch.cpp firefox-90.0/security/sandbox/linux/launch/SandboxLaunch.cpp
--- firefox-90.0.orig/security/sandbox/linux/launch/SandboxLaunch.cpp    2021-07-05 18:20:36.000000000 +0200
+++ firefox-90.0/security/sandbox/linux/launch/SandboxLaunch.cpp    2021-07-20 08:39:17.272136982 +0200   
@@ -501,8 +501,7 @@  
 MOZ_NEVER_INLINE MOZ_ASAN_BLACKLIST static pid_t DoClone(int aFlags,
                                                          jmp_buf* aCtx) {
   static constexpr size_t kStackAlignment = 16; 
-  uint8_t miniStack[PTHREAD_STACK_MIN]
-      __attribute__((aligned(kStackAlignment)));
+  uint8_t miniStack[4096] __attribute__((aligned(kStackAlignment)));  
 #ifdef __hppa__
   void* stackPtr = miniStack;
 #else
 0:01.65 dump_syms
 0:01.65 minidump-analyzer
 0:01.65 crashreporter
 0:01.75 webrtc-gtest
 0:01.80 libxul_s.a.desc
 0:01.80 libxul.so
 0:01.86 Executing: /usr/bin/g++ -std=gnu++14 -o dump_syms -freorder-blocks -O2 -O2 -g host_dump_syms.o ../../../common/linux/libhost_breakpad_linux_common_s.a ../../../common/libhost_breakpad_common_s.a ../../../common/dwarf/libhost_breakpad_dwarf_s.a
 0:01.86 /usr/bin/ld: ../../../common/libhost_breakpad_common_s.a(host_dwarf_cu_to_module.o): in function `std::__new_allocator<std::tr1::__detail::_Hash_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false>*>::allocate(unsigned long, void const*)':
 0:01.86 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.86 /usr/bin/ld: /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.86 /usr/bin/ld: ../../../common/dwarf/libhost_breakpad_dwarf_s.a(host_dwarf2reader.o): in function `std::__new_allocator<unsigned long long*>::allocate(unsigned long, void const*)':
 0:01.86 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.86 /usr/bin/ld: ../../../common/dwarf/libhost_breakpad_dwarf_s.a(host_dwarf2reader.o): in function `std::__new_allocator<dwarf2reader::CallFrameInfo::RuleMap*>::allocate(unsigned long, void const*)':
 0:01.86 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.86 /usr/bin/ld: ../../../common/dwarf/libhost_breakpad_dwarf_s.a(host_dwarf2diehandler.o): in function `std::__new_allocator<dwarf2reader::DIEDispatcher::HandlerStack*>::allocate(unsigned long, void const*)':
 0:01.86 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.86 collect2: error: ld returned 1 exit status
 0:01.87 gmake[4]: *** [/home/moroshima/firefox-60.9.0/config/rules.mk:601: dump_syms] Error 1
 0:01.87 gmake[3]: *** [/home/moroshima/firefox-60.9.0/config/recurse.mk:73: toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/host] Error 2
 0:01.87 gmake[3]: *** Waiting for unfinished jobs....
 0:01.90 Executing: /usr/bin/g++ -std=gnu++14 -o crashreporter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wc++1z-compat -Wduplicated-cond -Wimplicit-fallthrough -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wformat -Wformat-overflow=2 -fno-sized-deallocation -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -freorder-blocks -O2 -fomit-frame-pointer /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/tmpV2CRGT.list -lpthread -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,--build-id -Wl,-rpath-link,/home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/dist/bin -Wl,-rpath-link,/usr/local/lib -fdiagnostics-color -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lgthread-2.0 -pthread
 0:01.90 /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/tmpV2CRGT.list:
 0:01.90     INPUT("Unified_cpp_client0.o")
 0:01.90     INPUT("../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o")
 0:01.90     INPUT("../google-breakpad/src/common/linux/file_id.o")
 0:01.90     INPUT("../google-breakpad/src/common/linux/Unified_cpp_src_common_linux0.o")
 0:01.90
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `Json::Value::asString[abi:cxx11]() const':
 0:01.90 /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:695: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `Json::Value::asInt() const':
 0:01.90 /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:715: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:718: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:728: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:712: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o:/home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:737: more undefined references to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()' follow
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `std::__new_allocator<Json::Reader::ErrorInfo*>::allocate(unsigned long, void const*)':
 0:01.90 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `std::__new_allocator<Json::Value**>::allocate(unsigned long, void const*)':
 0:01.90 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `std::__new_allocator<Json::Reader::ErrorInfo*>::allocate(unsigned long, void const*)':
 0:01.90 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `std::__new_allocator<Json::OurReader::ErrorInfo*>::allocate(unsigned long, void const*)':
 0:01.90 /usr/include/c++/12/bits/new_allocator.h:125: undefined reference to `std::__throw_bad_array_new_length()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `Json::Value::resize(unsigned int)':
 0:01.90 /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:961: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 /usr/bin/ld: /home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/client/../../components/jsoncpp/src/lib_json/Unified_cpp_src_lib_json0.o: in function `Json::Value::resolveReference(char const*)':
 0:01.90 /home/moroshima/firefox-60.9.0/toolkit/components/jsoncpp/src/lib_json/json_value.cpp:1033: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
 0:01.90 collect2: error: ld returned 1 exit status
 0:01.90 gmake[4]: *** [/home/moroshima/firefox-60.9.0/config/rules.mk:566: crashreporter] Error 1
 0:01.90 gmake[3]: *** [/home/moroshima/firefox-60.9.0/config/recurse.mk:73: toolkit/crashreporter/client/target] Error 2

std::throw_bad_array_new_length() 和 std::cxx11::basic_ostringstream<char, std::char_traits, std::allocator >::basic_ostringstream() undefined

目前没找到合理的解决方案,有类似的问题是通过给 gcc 打 patch 的方式规避的(但是是gcc12)

https://bugzilla.mozilla.org/show_bug.cgi?id=1758005

但我上面所遇到的问题应该不是 gcc 的缺陷

问题应该是在链接阶段出现的,链接阶段会链接 libstdc++.so.6,不知道相关实现是否与 glibc 有所牵扯

Moroshima commented 1 year ago
moroshima@Haruna:~/firefox-60.9.0$ ldd --version
ldd (Debian GLIBC 2.36-9+deb12u1) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
Moroshima commented 1 year ago

以前以为alpine linux默认不用glibc有什么大不了的,直到自己开始折腾旧代码接触libstdc++和glibc打交道,才发现这下真的十几岁的时候无意间打出的那发子弹十年后击中了二十几岁的我了(

社区给出的解决方案几乎全是使用合适的 libstdc++ 版本

Every GCC release is accompanied by its very own libstdc++ release.

https://stackoverflow.com/questions/64766212/old-gcc-can-not-automatically-find-the-new-version-libstdc

https://bugs.launchpad.net/votca/+bug/1956898

https://forums.gentoo.org/viewtopic-t-1135215-start-0.html

后续需要和老师进行交流并确定下一步的方向

Moroshima commented 1 year ago

此时 gcc 切回 12 可解决,可以确认是 gcc 与 libstdc++ 兼容问题

moroshima@Haruna:~/firefox-60.9.0$ MOZ_SYSTEM_LIBEVENT=1 ./mach build
/home/moroshima/firefox-60.9.0/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py:263: UserWarning: psutil failed to run: not sure how to interpret line '   1       0 ram0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n'
  warnings.warn('psutil failed to run: %s' % e)
 0:00.17 Failed to parse ccache stats output: Local storage:
 0:00.19 Clobber not needed.
 0:00.19 Adding make options from None
    MOZ_OBJDIR=/home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu
    OBJDIR=/home/moroshima/firefox-60.9.0/obj-x86_64-pc-linux-gnu
 0:00.19 /usr/bin/gmake -f client.mk -s
 0:00.34 Elapsed: 0.00s; From dist/private: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.34 Elapsed: 0.00s; From dist/public: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.35 Elapsed: 0.00s; From dist/xpi-stage: Kept 14 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.42 Elapsed: 0.08s; From dist/idl: Kept 918 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.48 Elapsed: 0.14s; From _tests: Kept 995 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.58 Elapsed: 0.24s; From dist/bin: Kept 2195 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.80 Elapsed: 0.46s; From dist/include: Kept 5375 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:00.81 buildid.h
 0:00.89 source-repo.h
 0:00.99 application.ini
 0:01.08 application.ini.h
 0:01.16 Elapsed: 0.08s; From ../../dist/idl: Kept 918 existing; Added/updated 0; Removed 0 files and 0 directories.
 0:01.29 force-cargo-library-build
 0:01.45     Finished release [optimized] target(s) in 0.14s
 0:01.66 dump_syms
 0:01.66 minidump-analyzer
 0:01.66 crashreporter
 0:01.76 webrtc-gtest
 0:01.78 libxul.so
 0:01.82 Executing: /usr/bin/g++ -std=gnu++14 -o dump_syms -freorder-blocks -O2 -O2 -g host_dump_syms.o ../../../common/linux/libhost_breakpad_linux_common_s.a ../../../common/libhost_breakpad_common_s.a ../../../common/dwarf/libhost_breakpad_dwarf_s.a
 0:01.82 /usr/bin/ld: host_dump_syms.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
 0:01.82 /usr/bin/ld: failed to set dynamic section sizes: bad value
 0:01.82 collect2: error: ld returned 1 exit status
 0:01.83 gmake[4]: *** [/home/moroshima/firefox-60.9.0/config/rules.mk:601: dump_syms] Error 1
 0:01.83 gmake[3]: *** [/home/moroshima/firefox-60.9.0/config/recurse.mk:73: toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/host] Error 2
 0:01.83 gmake[3]: *** Waiting for unfinished jobs....
 0:02.19 firefox
 0:24.76 /usr/bin/ld: warning: ../../../toolkit/library/StaticXULComponents.ld contains output sections; did you forget -T?
 0:25.74 gmake[2]: *** [/home/moroshima/firefox-60.9.0/config/recurse.mk:33: compile] Error 2
 0:25.74 gmake[1]: *** [/home/moroshima/firefox-60.9.0/config/rules.mk:442: default] Error 2
 0:25.74 gmake: *** [client.mk:169: build] Error 2
 0:25.76 0 compiler warnings present.
 0:25.76 Failed to parse ccache stats output: Local storage:

https://stackoverflow.com/questions/19364969/compilation-fails-with-relocation-r-x86-64-32-against-rodata-str1-8-can-not

heroxbd commented 1 year ago

Moroshima @.***> writes:

以前以为alpine linux默认不用glibc有什么大不了的,知道自己开始折腾旧代 码接触libstdc++和glibc打交道,才发现这下真的十几岁的时候无意间打出的那 发子弹十年后击中了二十几岁的我了(

社区给出的解决方案几乎全是使用合适的 libstdc++ 版本

Every GCC release is accompanied by its very own libstdc++ release.

libstdc++ 是 GCC 的库,与 glibc 没有关系。我看不懂你的叙述,是不是把两者 搞混了?

Moroshima commented 1 year ago

Moroshima @.***> writes: 以前以为alpine linux默认不用glibc有什么大不了的,知道自己开始折腾旧代 码接触libstdc++和glibc打交道,才发现这下真的十几岁的时候无意间打出的那 发子弹十年后击中了二十几岁的我了( 社区给出的解决方案几乎全是使用合适的 libstdc++ 版本 Every GCC release is accompanied by its very own libstdc++ release. libstdc++ 是 GCC 的库,与 glibc 没有关系。我看不懂你的叙述,是不是把两者 搞混了?

我对 libstdc++ 的理解是其会将 glibc 进行封装并暴露 API,不知道这样的理解是不是存在问题。

在链接时则会链接 libstdc++.so

很多情况下 libstdc++ 似乎是直接与 glibc 版本绑定的(绝大多数情况下 gcc 版本也会和 libstdc++ 存在绑定,但这是可以介入更易的,我们可以使用旧版本 gcc + 新版本 libstdc++)

strings /usr/lib32/libstdc++.so.6 | grep GLIBCXX
heroxbd commented 1 year ago

Moroshima @.***> writes:

我对 libstdc++ 的理解是其会将 glibc 进行封装并暴露 API,不知道这样的理 解是不是存在问题。

一切 library 的调用最终都归结到 glibc 和 kernel API 。上述表述不是 libstdc++ 特有的,对所有 library 都适用。

在链接时编译器则会链接 libstdc++.so

是的

很多情况下 libstdc++ 似乎是直接与 glibc 版本绑定的

错误,libstdc++ 没有与 glibc 绑定一说。

strings /usr/lib32/libstdc++.so.6 | grep GLIBCXX

这仅是因为这个 GCC 在编译时,用到了 GLIBC 特定版本的某些特性。

另外,为什么要用 /usr/lib32 32 位的库举例?

Moroshima commented 1 year ago

libstdc++ 没有与 glibc

确实是我表述不当,libstdc++ 是依赖 glibc

其实举例只是随便举的(