https://sourceware.org/bugzilla/show_bug.cgi?id=30915
Bug ID: 30915 Summary: ld testsuite: visibility incorrectly marked XFAIL on musl targets Product: binutils Version: 2.41 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: awilfox at adelielinux dot org Target Milestone: --- On an x86_64-foxkit-linux-musl system: Running /home/awilcox/Code/binutils-next/system/binutils/src/binutils-2.41/ld/testsuite/ld-vsb/vsb.exp ... XPASS: visibility (protected) XPASS: visibility (protected) (PIC main) XPASS: visibility (protected_undef_def) XPASS: visibility (protected_undef_def) (PIC main) On a armv7-foxkit-linux-musl system: XPASS: visibility (hidden_undef) (non PIC) XPASS: visibility (hidden_undef) (non PIC, load offset) XPASS: visibility (hidden_undef) (PIC main, non PIC so) XPASS: visibility (protected_undef) (non PIC) XPASS: visibility (protected_undef) (non PIC, load offset) XPASS: visibility (protected_undef) (PIC main, non PIC so) Digging in, the x86_64 failures are because of lines 408-413 of vsb.exp: if { [ string match $visibility "protected" ] || [ string match $visibility "protected_undef_def" ] } { if [ string match $support_protected "no" ] { setup_xfail $target_triplet } } The "$support_protected" variable is set on lines 119-123: if [ld_compile "$CC_FOR_TARGET -g -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] { if [ld_link $CC_FOR_TARGET $tmpdir/main "$tmpdir/main.o"] { catch "exec $tmpdir/main" support_protected } } Where the test's main.c is, in entirety, when PROTECTED_CHECK is defined: #include <features.h> #include <stdio.h> int main (void) { #if defined (__GLIBC__) && (__GLIBC__ > 2 \ || (__GLIBC__ == 2 \ && __GLIBC_MINOR__ >= 2)) puts ("yes"); #else puts ("no"); #endif return 0; } That is.. not a very helpful test for musl targets. I don't know the best way forward for this. There is no preprocessor macro test for musl targets, so I would suggest something akin to changing the first line from: #if defined (__GLIBC__) && (__GLIBC__ > 2 \ || (__GLIBC__ == 2 \ && __GLIBC_MINOR__ >= 2)) to: #if !defined (__GLIBC__) || (__GLIBC__ > 2 \ || (__GLIBC__ == 2 \ && __GLIBC_MINOR__ >= 2)) This would mean the protected-check is assumed to work on all implementations that are not glibc <2.2. I don't know if some of the more "odd" targets (like Bionic) might then fail. I know that µClibc defines __GLIBC__ == 2 and __GLIBC_MINOR__ == 2, so this at least shouldn't break that target. Similarly, for armv7, we have lines 104-111 testing whether non-PIC tests should XFAIL: if [istarget arm*-*-*eabi*] { set file [open $tmpdir/movw-detect.c w] puts $file "void foo(void) { __asm (\"movw r0, #0\"); }" close $file if [run_host_cmd_yesno "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] { set shared_needs_pic "yes" } } With a rationale in a block comment spanning lines 99-103: # On targets that have MOVW the compiler will emit relocations which # the linker doesn't support when compiling -shared without -fpic. The # test to find out whether we want to XFAIL the non-PIC tests requires # a compile - so we pre-calculate it here. We also note that this can # only affect arm*-*-*eabi* targets as the old ABI doesn't support v7. This seems correct but incomplete: /home/awilcox/trees/binutils-next/system/binutils/src/binutils-2.41/ld/.libs/lt-ld-new: tmpdir/sh1np.o: relocation R_ARM_THM_MOVW_ABS_NC against `shlibvar1' can not be used when making a shared object; recompile with -fPIC tmpdir/sh1np.o: in function `shlib_check': /home/awilcox/trees/binutils-next/system/binutils/src/binutils-2.41/ld/testsuite/ld-vsb/sh1.c:170:(.text+0x11c): dangerous relocation: unsupported relocation /home/awilcox/trees/binutils-next/system/binutils/src/binutils-2.41/ld/.libs/lt-ld-new: tmpdir/sh1np.o: in function `visibility_checkfunptr': /home/awilcox/trees/binutils-next/system/binutils/src/binutils-2.41/ld/testsuite/ld-vsb/sh1.c:216:(.text+0x124): undefined reference to `visibility' [ .. snip .. ] The unsupported relocation does happen but is not a fatal error so the test finds the matching regex line ("undefined reference to `visibility'") and XPASSes. Each arch may be its own bug, but I'm not entirely sure, so I decided to file one bug to not clutter the tracker. If the 32-bit Arm bug should be split out to its own bug, I can do that. -- You are receiving this mail because: You are on the CC list for the bug.