-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools/elfutils: do not link gnulib to libelf #15368
Conversation
Getting :
|
macOS 14.4.1 Intel:
make tools/elfutils/{clean,compile} -j 1 V=s
…
/usr/bin/env bash ../libtool --tag=CC --mode=link /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -Wl,-rpath-link,../libelf:../libdw -L/Volumes/test/m/openwrt/staging_dir/host/lib -o elflint elflint.o ../libebl/libebl.la ../backends/libebl_backends.la ../libcpu/libcpu.la ../libdw/libdw.la -lz ../libelf/libelf.la -lz -ldl -lpthread ../libelf/libelf.la -lz ../lib/libeu.la /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/libgnu.la
OpenWrt-libtool: link: /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -Wl,-rpath-link -Wl,../libelf:../libdw -o elflint elflint.o -L/Volumes/test/m/openwrt/staging_dir/host/lib ../libebl/.libs/libebl.a ../backends/.libs/libebl_backends.a ../libcpu/.libs/libcpu.a ../libdw/.libs/libdw.a -ldl ../libelf/.libs/libelf.a -lpthread -lz ../lib/.libs/libeu.a /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/.libs/libgnu.a
ld: unknown options: -rpath-link
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [Makefile:1655: elflint] Error 1
make[4]: *** [Makefile:1480: all-recursive] Error 1
make[3]: *** [Makefile:1387: all] Error 2
make[3]: Leaving directory '/Volumes/test/m/openwrt/build_dir/host/elfutils-0.191'
make[2]: *** [Makefile:103: /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/.built] Error 2
make[2]: Leaving directory '/Volumes/test/m/openwrt/tools/elfutils' x64.2024-05-03.01-gnulib-macos.txt |
yeah the CI showed the same thing ... |
a341051
to
76e9d59
Compare
ok let's give it another try, this time there are more variable overrides... the rpath-link option is for shared libraries only, and we no longer build them as shared here... @httpstorm can you also show output of this
|
ah great... more linking problems |
@httpstorm now I need to see.....
|
nevermind I got it, they are defined with
|
/usr/bin/env bash ../libtool --tag=CC --mode=link /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -L/Volumes/test/m/openwrt/staging_dir/host/lib -o elflint elflint.o ../libebl/libebl.la ../backends/libebl_backends.la ../libcpu/libcpu.la ../libdw/libdw.la -lz ../libelf/libelf.la -lz -ldl -lpthread ../libelf/libelf.la -lz ../lib/libeu.la /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/libgnu.la
OpenWrt-libtool: link: /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -o elflint elflint.o -L/Volumes/test/m/openwrt/staging_dir/host/lib ../libebl/.libs/libebl.a ../backends/.libs/libebl_backends.a ../libcpu/.libs/libcpu.a ../libdw/.libs/libdw.a -ldl ../libelf/.libs/libelf.a -lpthread -lz ../lib/.libs/libeu.a /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/.libs/libgnu.a
Undefined symbols for architecture x86_64:
"_default_none_reloc_p", referenced from:
_openbackend in libebl.a[2](eblopenbackend.o)
_openbackend in libebl.a[2](eblopenbackend.o)
"_default_relative_reloc_p", referenced from:
_openbackend in libebl.a[2](eblopenbackend.o)
_openbackend in libebl.a[2](eblopenbackend.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [Makefile:1655: elflint] Error 1
make[4]: *** [Makefile:1480: all-recursive] Error 1
make[3]: *** [Makefile:1387: all] Error 2 x64.2024-05-03.03-elfutils-macos.txt nm build_dir/host/elfutils-0.191/libebl/.libs/libebl.a | grep default_
00000000000008d0 t _default_abi_cfi
00000000000006d0 t _default_auxv_info
0000000000000820 t _default_bss_plt_p
00000000000008a0 t _default_check_object_attribute
00000000000008c0 t _default_check_reloc_target_type
0000000000000640 t _default_check_special_section
00000000000007f0 t _default_check_special_symbol
0000000000000810 t _default_check_st_other_bits
00000000000007e0 t _default_copy_reloc_p
00000000000006c0 t _default_core_note
00000000000006a0 t _default_core_note_type_name
0000000000000800 t _default_data_marker_symbol
00000000000006f0 t _default_debugscn_p
0000000000001580 s _default_debugscn_p.dwarf_scn_names
00000000000008e0 t _default_destr
0000000000000680 t _default_dynamic_tag_check
0000000000000670 t _default_dynamic_tag_name
00000000000005d0 t _default_gotpc_reloc_check
0000000000000620 t _default_machine_flag_check
0000000000000610 t _default_machine_flag_name
0000000000000630 t _default_machine_section_flag_check
U _default_none_reloc_p
00000000000006e0 t _default_object_note
00000000000006b0 t _default_object_note_type_name
0000000000000690 t _default_osabi_name
0000000000000840 t _default_register_info
U _default_relative_reloc_p
00000000000005c0 t _default_reloc_simple_type
00000000000005a0 t _default_reloc_type_check
0000000000000590 t _default_reloc_type_name
00000000000005b0 t _default_reloc_valid_use
0000000000000830 t _default_return_value_location
0000000000000600 t _default_section_name
00000000000005f0 t _default_section_type_name
00000000000005e0 t _default_segment_type_name
0000000000000660 t _default_symbol_binding_name
0000000000000650 t _default_symbol_type_name cat libebl/eblopenbackend.c | grep default_none
static bool default_none_reloc_p (int reloc);
result->none_reloc_p = default_none_reloc_p;
strong_alias (default_copy_reloc_p, default_none_reloc_p)
cat libebl/eblopenbackend.c | grep default_relative
static bool default_relative_reloc_p (int reloc);
result->relative_reloc_p = default_relative_reloc_p;
strong_alias (default_copy_reloc_p, default_relative_reloc_p) |
76e9d59
to
887b1c6
Compare
@httpstorm now I'm confused... can you show this again with the new push?
|
887b1c6
to
7fa40d0
Compare
small rebase because I'm suspicious of the CI's results... all 3 functions have the exact same representation now:
|
What's your goal with this PR? On macOS, a lot of gnulib stuff is needed for libelf, and it seems more messy to me to try to deal with that in each package that depends on it. Wouldn't it be better to continue linking gnulib into libelf, but find a way to make the extra symbols hidden? |
7fa40d0
to
4161a5c
Compare
/usr/bin/env bash ../libtool --tag=CC --mode=link /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -L/Volumes/test/m/openwrt/staging_dir/host/lib -o unstrip unstrip.o ../libebl/libebl.la ../backends/libebl_backends.la ../libcpu/libcpu.la ../libelf/libelf.la -lz ../libdw/libdw.la -lz ../libelf/libelf.la -lz -ldl -lpthread ../lib/libeu.la /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/libgnu.la
OpenWrt-libtool: link: /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -o unstrip unstrip.o -L/Volumes/test/m/openwrt/staging_dir/host/lib ../libebl/.libs/libebl.a ../backends/.libs/libebl_backends.a ../libcpu/.libs/libcpu.a ../libdw/.libs/libdw.a ../libelf/.libs/libelf.a -lz -ldl -lpthread ../lib/.libs/libeu.a /Volumes/test/m/openwrt/build_dir/host/elfutils-0.191/libgnu/.libs/libgnu.a
Undefined symbols for architecture x86_64:
"_rpl_fts_close$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_open$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_read$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_set$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [Makefile:1699: unstrip] Error 1
make[4]: *** [Makefile:1480: all-recursive] Error 1
make[3]: *** [Makefile:1387: all] Error 2 x64.2024-05-04.01-elfutils-macos.txt nm build_dir/host/elfutils-0.191/libebl/.libs/libebl.a | grep default_
00000000000008f0 t _default_abi_cfi
00000000000006d0 t _default_auxv_info
0000000000000840 t _default_bss_plt_p
00000000000008c0 t _default_check_object_attribute
00000000000008e0 t _default_check_reloc_target_type
0000000000000640 t _default_check_special_section
0000000000000810 t _default_check_special_symbol
0000000000000830 t _default_check_st_other_bits
00000000000007e0 t _default_copy_reloc_p
00000000000006c0 t _default_core_note
00000000000006a0 t _default_core_note_type_name
0000000000000820 t _default_data_marker_symbol
00000000000006f0 t _default_debugscn_p
00000000000015a0 s _default_debugscn_p.dwarf_scn_names
0000000000000900 t _default_destr
0000000000000680 t _default_dynamic_tag_check
0000000000000670 t _default_dynamic_tag_name
00000000000005d0 t _default_gotpc_reloc_check
0000000000000620 t _default_machine_flag_check
0000000000000610 t _default_machine_flag_name
0000000000000630 t _default_machine_section_flag_check
00000000000007f0 t _default_none_reloc_p
00000000000006e0 t _default_object_note
00000000000006b0 t _default_object_note_type_name
0000000000000690 t _default_osabi_name
0000000000000860 t _default_register_info
0000000000000800 t _default_relative_reloc_p
00000000000005c0 t _default_reloc_simple_type
00000000000005a0 t _default_reloc_type_check
0000000000000590 t _default_reloc_type_name
00000000000005b0 t _default_reloc_valid_use
0000000000000850 t _default_return_value_location
0000000000000600 t _default_section_name
00000000000005f0 t _default_section_type_name
00000000000005e0 t _default_segment_type_name
0000000000000660 t _default_symbol_binding_name
0000000000000650 t _default_symbol_type_name
I see you just made more changes, I'll retest. |
/usr/bin/env bash ../libtool --tag=CC --mode=compile /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/Volumes/test/m/openwrt/staging_dir/host/share/locale"' -I. -I.. -I../libgnu -I../libgnu -I. -I. -I../lib -I.. -I/Volumes/test/m/openwrt/staging_dir/host/include -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -c -o elf_getshdrnum.lo elf_getshdrnum.c
OpenWrt-libtool: compile: /Volumes/test/m/openwrt/staging_dir/host/bin/gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR=\"/Volumes/test/m/openwrt/staging_dir/host/share/locale\" -I. -I.. -I../libgnu -I../libgnu -I. -I. -I../lib -I.. -I/Volumes/test/m/openwrt/staging_dir/host/include -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes -Wnull-dereference -Wimplicit-fallthrough -Werror -Wunused -Wextra -D_FORTIFY_SOURCE=3 -O2 -I/Volumes/test/m/openwrt/staging_dir/host/include -I/opt/homebrew/include -Wno-error -fPIC -fno-addrsig -c elf_getshdrnum.c -o elf_getshdrnum.o
In file included from elf_getshdrnum.c:38:
In file included from ./libelfP.h:43:
../lib/system.h:125:9: warning: 'gettext_noop' macro redefined [-Wmacro-redefined]
#define gettext_noop(Str) Str
^
../libgnu/gettext.h:109:9: note: previous definition is here
#define gettext_noop(String) String
^
elf_getshdrnum.c:87:1: error: aliases are not supported on darwin
strong_alias (elf_getshdrnum, elf_getshnum)
^
../libgnu/eu-config.h:70:54: note: expanded from macro 'strong_alias'
extern __typeof__ (name) aliasname __attribute__ ((alias (#name)));
^
1 warning and 1 error generated.
make[5]: *** [Makefile:1765: elf_getshdrnum.lo] Error 1
make[4]: *** [Makefile:1480: all-recursive] Error 1
make[3]: *** [Makefile:1387: all] Error 2 x64.2024-05-04.02-elfutils-macos.txt nm build_dir/host/elfutils-0.191/libebl/.libs/libebl.a | grep default_
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: error: build_dir/host/elfutils-0.191/libebl/.libs/libebl.a: No such file or directory grep -rnw build_dir/host/elfutils-0.191 -e 'default_copy_reloc_p'
build_dir/host/elfutils-0.191/libebl/ChangeLog:1112: (default_copy_reloc_p): New function.
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:200:static bool default_copy_reloc_p (int reloc);
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:253: result->copy_reloc_p = default_copy_reloc_p;
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:633:default_copy_reloc_p (int reloc __attribute__ ((unused)))
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:637:strong_alias (default_copy_reloc_p, default_none_reloc_p)
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:638:strong_alias (default_copy_reloc_p, default_relative_reloc_p)
grep -rnw build_dir/host/elfutils-0.191 -e 'default_none_reloc_p'
build_dir/host/elfutils-0.191/libebl/ChangeLog:736: * eblopenbackend.c (default_none_reloc_p): New function.
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:201:static bool default_none_reloc_p (int reloc);
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:254: result->none_reloc_p = default_none_reloc_p;
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:637:strong_alias (default_copy_reloc_p, default_none_reloc_p)
grep -rnw build_dir/host/elfutils-0.191 -e 'default_relative_reloc_p'
build_dir/host/elfutils-0.191/libebl/ChangeLog:727: * eblopenbackend.c (default_relative_reloc_p): New function.
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:202:static bool default_relative_reloc_p (int reloc);
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:255: result->relative_reloc_p = default_relative_reloc_p;
build_dir/host/elfutils-0.191/libebl/eblopenbackend.c:638:strong_alias (default_copy_reloc_p, default_relative_reloc_p) |
I'm running on the philosophy of "let the linker decide each time", and while it may be common for multiple libraries to provide the same function, it's the opposite of common for the same library to provide the same function again like we saw with the issue mentioned. To me, that stuck out as a build design flaw more than a coincidence. Also, I don't think it's reasonable to stuff a built library with functions already available on the host machine's standard libraries. Gnulib is designed to cover its own dependencies as needed, and several of the functions aren't needed. If this were to happen again, but with a module that we actually needed to keep, it would mean another huge patch for gnulib to fix (the right way) or some wild workaround in that program/package (the quick and dirty way) and probably neither upstream project would like those changes so we would be stuck with it. I'm hoping it's easy or even not necessary to include gnulib for other packages that depend on libelf, but if it turns out to be ridiculous I'll just let go of the idea. I was also thinking about the possibility of installing them side-by-side instead of linking them together, so only an extra link flag would have to be added to a package... But we are currently stuck with just building some of the binaries on macOS, which is another thing I wanted to see happen if possible... |
well I lost that bet I'm being slightly mislead, don't believe everything on forums 😆 |
4161a5c
to
38d45c2
Compare
@mpratt14 Best of luck! I admire your motivation to experiment and improve. 😊 |
thanks for the participation Georgi, even if we might be wasting time... I'm a little apprehensive to try the reverse shell runner, normal CI runs are giving enough info this time anyway... at the very least, your system's errors agree with the CI... except for those 3 functions that should be treated the same... but now I got rid of them... |
Undefined symbols for architecture x86_64:
"_rpl_fts_close$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_open$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_read$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
_dwfl_linux_kernel_report_modules in libdw.a[189](linux-kernel-modules.o)
"_rpl_fts_set$INODE64", referenced from:
_dwfl_linux_kernel_report_offline in libdw.a[189](linux-kernel-modules.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation) |
ca765be
to
e3309d3
Compare
@httpstorm so if you could show your system's fts header maybe that would show whats going on...
|
find /usr/lib /usr/local/include /usr/include | grep fts.h
find: ‘/usr/include’: No such file or directory
find /usr | grep fts.h
find: ‘/usr/sbin/authserver’: Permission denied
/usr/local/Cellar/libwebsockets/4.3.3/include/libwebsockets/lws-fts.h
find /Applications/Xcode.app | grep 'fts\.h'
/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/usr/include/fts.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/fts.h It's here
|
d7c2aa3
to
1fe39e3
Compare
@httpstorm ready for you to give it a try again |
@robimarko that's exactly why I'm trying to do extra preventative maintenance now instead of waiting until the next release... It's clear to see how much of a mess it is, so I want to make the next future version bump very easy... If it seems like this is happening all at once, it's just because the way support for macOS was added in the first place was such a large change by itself, the clean up is naturally a little chaotic. After this, I'm going to post a PR for greatly reducing the size of the patch. Making robust variable overrides in our Makefile in this PR is part of that process. Some lines will still look fairly complex at first glance, but they can be explained easily once understood. I think a few Makefile complexities will be worth it to end up with 500 less lines in |
by the way, I should add... I talk a lot about reducing the size of the patch yet this PR is basically only adding lines... However, that's only because of trying to build binaries again after they were disabled, except for the ones that would conflict with the toolchain as described in the commit |
I am not talking specifically about this PR but the amount of macOS fixes that are constantly being added in general and those are really getting out of hand |
so does this look good? should I rebase so that I can put the added gnulib module alphabetically without conflict? |
fd0f7a8
to
0e304ec
Compare
rebased, and updated commit messages |
0e304ec
to
ac91693
Compare
My Mac Mini at work is currently down as they are upgrading the network and VPN access so I cant test this currently |
Builds fine on macOS 14.5 Intel, |
Well, this is breaking elfutils compilation on Fedora 40 (GCC 14.1.1)
|
@robimarko try adding |
...and if not put |
we should consider a default value for |
@mpratt14 Adding |
ac91693
to
d1d28b9
Compare
The gnulib fts header is meant to not be overwritten in any way by the host system's copy of fts.h and was therefore given a unique name instead. This is fine if the built libgnu library is directly linked with the target library, but if we want to keep them isolated we end up having the definitions being mangled anyway when the next object to link against included the fts.h header. On some macOS platforms, the use of __DARWIN_INODE64 is messing with the link name for fts functions, resulting in: Undefined symbols for architecture x86_64: "_rpl_fts_close$INODE64", referenced from: ... Create a local fts header for gnulib that completely blocks the macOS host fts header. An alternative and more upstream friendly fix would be to rename fts_.h to fts.h and add the macOS-only include guard to that file within it's own include guard, but that would be a massive patch, so do this for now. Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
Install binaries that are not common with binutils instead of none at all. This adds a negligible time to the build. Building shared libraries is disabled, so the AM_LDFLAGS can be reset without the rpath-link option which is unrecognized by clang. Some of the binaries depend on functions that are defined using a "strong alias" instead of a normal definition, but this is disabled by our patches in order to work on macOS, so use the identical function directly instead. Add fnmatch from gnulib with GNU extensions which is needed for usage of the FNM_EXTMATCH flag. Handle a "Wunused-const-variable" error with the same preprocessor conditional used to include the function that the variable is used in. Ref: f64bd4b ("tools/elfutils: only build required components") Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
The compiled library resulting from importing gnulib has been linked to libelf in order to easily cover other link dependencies. However, this is not appropriate for linking libelf to other programs as it bloats the resulting libelf library, and may result in multiple defintions of symbols based on whether or not certain modules from gnulib are included while elfutils already has it's own definition of a function. This is not a problem while building elfutils, because gnulib has it's own way of creating function aliases and special declarations that allow the linker to ignore the original function definitions, however, when libelf is used to link to something else, this results in an error at link time. The gnulib manual recommended linking the libraries directly, but those who have written it may not have considered how this can affect the ability to link that library in other builds, they likely assume the build targets would not be a dependency. Fix this by removing the linking between gnulib and libelf and instead overriding Make variables in order to add linking between gnulib and each of the binaries provided by elfutils, using Make functions to avoid applying it to other subdirectories. The function tdestroy() would still be missing on macOS, but the existence of the gnulib tsearch object having been built is an indicator of whether or not it is needed because it is only built conditionally by gnulib, so include linking that object only when it exists. Block the unnecessary replacement of some functions by gnulib so that future linking with libelf doesn't require the associated gnulib "rpl" prefixed functions. These replacements are very strict in order to correct minor bugs that don't have a real impact in almost all cases or new standards requirements that are not yet in effect or used. Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
Trying to compile elfutils on Fedora 40 with GCC 14.1.1 will fail with: /home/robimarko/Building/AX3600/qualcommax/staging_dir/host/bin/g++ -std=c++11 -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/share/locale"' -DDEBUGPRED=0 -DSRCDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -DOBJDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -I. -I.. -I../libgnu -I../libgnu -I. -I. -I../lib -I.. -I./../libelf -I./../libebl -I./../libdw -I./../libdwelf -I./../libdwfl -I./../libasm -I../debuginfod -I/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/include -std=c++11 -Wall -Wshadow -Wtrampolines -Wlogical-op -Wduplicated-cond -Wnull-dereference -Wimplicit-fallthrough=5 -Werror -Wunused -Wextra -Wstack-usage=262144 -D_FORTIFY_SOURCE=3 -c -o srcfiles.o srcfiles.cxx In file included from /usr/include/c++/14/x86_64-redhat-linux/bits/os_defines.h:39, from /usr/include/c++/14/x86_64-redhat-linux/bits/c++config.h:2521, from /usr/include/c++/14/cstdlib:41, from ../libgnu/gettext.h:56, from ../libgnu/eu-config.h:62, from ../config.h:2378, from srcfiles.cxx:31: /usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~~~~~ cc1plus: all warnings being treated as errors So, lets do as the error says and pass -O2 in HOST_CXXFLAGS like we already do by default in HOST_CFLAGS. Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
d1d28b9
to
4454361
Compare
Thanks! Rebased on top of main and merged! |
@mpratt14 Congratulations, and thanks for the hard work. 🍻 |
now it's time to attack the size of the patch, phase 2 coming soon... |
The gnulib fts header is meant to not be overwritten in any way by the host system's copy of fts.h and was therefore given a unique name instead. This is fine if the built libgnu library is directly linked with the target library, but if we want to keep them isolated we end up having the definitions being mangled anyway when the next object to link against included the fts.h header. On some macOS platforms, the use of __DARWIN_INODE64 is messing with the link name for fts functions, resulting in: Undefined symbols for architecture x86_64: "_rpl_fts_close$INODE64", referenced from: ... Create a local fts header for gnulib that completely blocks the macOS host fts header. An alternative and more upstream friendly fix would be to rename fts_.h to fts.h and add the macOS-only include guard to that file within it's own include guard, but that would be a massive patch, so do this for now. Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
Install binaries that are not common with binutils instead of none at all. This adds a negligible time to the build. Building shared libraries is disabled, so the AM_LDFLAGS can be reset without the rpath-link option which is unrecognized by clang. Some of the binaries depend on functions that are defined using a "strong alias" instead of a normal definition, but this is disabled by our patches in order to work on macOS, so use the identical function directly instead. Add fnmatch from gnulib with GNU extensions which is needed for usage of the FNM_EXTMATCH flag. Handle a "Wunused-const-variable" error with the same preprocessor conditional used to include the function that the variable is used in. Ref: f64bd4b ("tools/elfutils: only build required components") Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
The compiled library resulting from importing gnulib has been linked to libelf in order to easily cover other link dependencies. However, this is not appropriate for linking libelf to other programs as it bloats the resulting libelf library, and may result in multiple defintions of symbols based on whether or not certain modules from gnulib are included while elfutils already has it's own definition of a function. This is not a problem while building elfutils, because gnulib has it's own way of creating function aliases and special declarations that allow the linker to ignore the original function definitions, however, when libelf is used to link to something else, this results in an error at link time. The gnulib manual recommended linking the libraries directly, but those who have written it may not have considered how this can affect the ability to link that library in other builds, they likely assume the build targets would not be a dependency. Fix this by removing the linking between gnulib and libelf and instead overriding Make variables in order to add linking between gnulib and each of the binaries provided by elfutils, using Make functions to avoid applying it to other subdirectories. The function tdestroy() would still be missing on macOS, but the existence of the gnulib tsearch object having been built is an indicator of whether or not it is needed because it is only built conditionally by gnulib, so include linking that object only when it exists. Block the unnecessary replacement of some functions by gnulib so that future linking with libelf doesn't require the associated gnulib "rpl" prefixed functions. These replacements are very strict in order to correct minor bugs that don't have a real impact in almost all cases or new standards requirements that are not yet in effect or used. Tested-by: Georgi Valkov <gvalkov@gmail.com> # macOS Signed-off-by: Michael Pratt <mcpratt@pm.me> Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
Trying to compile elfutils on Fedora 40 with GCC 14.1.1 will fail with: /home/robimarko/Building/AX3600/qualcommax/staging_dir/host/bin/g++ -std=c++11 -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/share/locale"' -DDEBUGPRED=0 -DSRCDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -DOBJDIR=\"/home/robimarko/Building/AX3600/qualcommax/build_dir/host/elfutils-0.191/src\" -I. -I.. -I../libgnu -I../libgnu -I. -I. -I../lib -I.. -I./../libelf -I./../libebl -I./../libdw -I./../libdwelf -I./../libdwfl -I./../libasm -I../debuginfod -I/home/robimarko/Building/AX3600/qualcommax/staging_dir/host/include -std=c++11 -Wall -Wshadow -Wtrampolines -Wlogical-op -Wduplicated-cond -Wnull-dereference -Wimplicit-fallthrough=5 -Werror -Wunused -Wextra -Wstack-usage=262144 -D_FORTIFY_SOURCE=3 -c -o srcfiles.o srcfiles.cxx In file included from /usr/include/c++/14/x86_64-redhat-linux/bits/os_defines.h:39, from /usr/include/c++/14/x86_64-redhat-linux/bits/c++config.h:2521, from /usr/include/c++/14/cstdlib:41, from ../libgnu/gettext.h:56, from ../libgnu/eu-config.h:62, from ../config.h:2378, from srcfiles.cxx:31: /usr/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~~~~~ cc1plus: all warnings being treated as errors So, lets do as the error says and pass -O2 in HOST_CXXFLAGS like we already do by default in HOST_CFLAGS. Link: openwrt#15368 Signed-off-by: Robert Marko <robimarko@gmail.com>
ping @robimarko @httpstorm @trippleflux
This is the direct/general way to stop extra symbols from being in libelf
(I also noticed that we weren't installing any binaries and found the reason for that, so lets just install the unique ones)
This is purposefully not rebased on top so that it can be shown that it also fixes openwrt/packages#24030
alongside with #15337 which just removes the actual extra definition in that specific case
Of course, this needs testing on macOS, as I have a feeling there is some other reason that they were linked together
that I just can't see because it only applies to macOS...