public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS
@ 2021-06-17 19:01 mose at gnu dot org
  2021-06-17 22:17 ` [Bug sanitizer/101111] " mose at gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-17 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

            Bug ID: 101111
           Summary: Undefined reference to ___lsan_default_suppressions
                    when compiling GCC 11.1 for x86_64 macOS
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mose at gnu dot org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

I'm trying to cross-compile GCC 11.1 for x86_64-apple-darwin on an
x86_64-linux-musl host.  You can find the full build script at
https://github.com/giordano/Yggdrasil/blob/2597ce2a3fdc4689ce089730263386d979fa1f65/0_RootFS/gcc_common.jl#L274-L778.
 The macOS SDK used is version 10.12.

When doing the final compilation, line 771 of the fine linked above,
compilation of libasan fails with the following error:


[10:03:02] libtool: link: (cd .libs/libasan.lax/libsanitizer_lsan.a &&
/workspace/destdir/bin/llvm-ar x
"/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libsanitizer/asan/../lsan/.libs/libsanitizer_l[49/1977]
[10:03:02] libtool: link:  /workspace/srcdir/gcc_build/./gcc/xgcc
-shared-libgcc -B/workspace/srcdir/gcc_build/./gcc -nostdinc++
-L/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libstdc++-v3/src
-L/workspace
/srcdir/gcc_build/x86_64-apple-darwin14/libstdc++-v3/src/.libs
-L/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs
-B/workspace/destdir/x86_64-apple-darwin14/bin/ -B/workspace/destd
ir/x86_64-apple-darwin14/lib/ -isystem
/workspace/destdir/x86_64-apple-darwin14/include -isystem
/workspace/destdir/x86_64-apple-darwin14/sys-include    -dynamiclib  -o
.libs/libasan.6.dylib  .libs/asan_activat
ion.o .libs/asan_allocator.o .libs/asan_debugging.o .libs/asan_descriptions.o
.libs/asan_errors.o .libs/asan_fake_stack.o .libs/asan_flags.o
.libs/asan_globals.o .libs/asan_interceptors.o .libs/asan_interceptor
s_memintrinsics.o .libs/asan_linux.o .libs/asan_mac.o .libs/asan_malloc_linux.o
.libs/asan_malloc_mac.o .libs/asan_malloc_win.o .libs/asan_memory_profile.o
.libs/asan_new_delete.o .libs/asan_poisoning.o .libs/a
san_posix.o .libs/asan_premap_shadow.o .libs/asan_report.o .libs/asan_rtems.o
.libs/asan_rtl.o .libs/asan_shadow_setup.o .libs/asan_stack.o
.libs/asan_stats.o .libs/asan_suppressions.o .libs/asan_thread.o .libs
/asan_win.o .libs/asan_win_dll_thunk.o .libs/asan_win_dynamic_runtime_thunk.o
.libs/asan_interceptors_vfork.o  
.libs/libasan.lax/libsanitizer_common.a/sancov_flags.o
.libs/libasan.lax/libsanitizer_common.a/san
itizer_allocator.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_allocator_checks.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_allocator_report.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_com
mon.o .libs/libasan.lax/libsanitizer_common.a/sanitizer_common_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_coverage_libcdep_new.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_deadlock_detec
tor1.o .libs/libasan.lax/libsanitizer_common.a/sanitizer_deadlock_detector2.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_errno.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_file.o .libs/libasan.lax
/libsanitizer_common.a/sanitizer_flag_parser.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_flags.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_libc.o
.libs/libasan.lax/libsanitizer_common.a/sanitize
r_libignore.o .libs/libasan.lax/libsanitizer_common.a/sanitizer_linux.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_linux_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_linux_s390.o .libs/lib
asan.lax/libsanitizer_common.a/sanitizer_mac.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_mac_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_netbsd.o
.libs/libasan.lax/libsanitizer_common.a/
sanitizer_openbsd.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_persistent_allocator.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_platform_limits_freebsd.o
.libs/libasan.lax/libsanitizer_common.a/s
anitizer_platform_limits_linux.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_platform_limits_openbsd.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_platform_limits_posix.o
.libs/libasan.lax/libsaniti
zer_common.a/sanitizer_platform_limits_solaris.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_posix.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_posix_libcdep.o
.libs/libasan.lax/libsanitizer_common
.a/sanitizer_printf.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_procmaps_bsd.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_procmaps_common.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_procm
aps_linux.o .libs/libasan.lax/libsanitizer_common.a/sanitizer_procmaps_mac.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_procmaps_solaris.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_rtems.o .libs/
libasan.lax/libsanitizer_common.a/sanitizer_solaris.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_stackdepot.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_stacktrace.o
.libs/libasan.lax/libsanitizer
_common.a/sanitizer_stacktrace_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_stacktrace_printer.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_stacktrace_sparc.o
.libs/libasan.lax/libsanitize
r_common.a/sanitizer_stoptheworld_linux_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_stoptheworld_mac.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_suppressions.o
.libs/libasan.lax/libsanit
izer_common.a/sanitizer_symbolizer.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_symbolizer_libbacktrace.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_symbolizer_libcdep.o
.libs/libasan.lax/libsanit
izer_common.a/sanitizer_symbolizer_mac.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_symbolizer_posix_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_symbolizer_report.o
.libs/libasan.lax/libs
anitizer_common.a/sanitizer_symbolizer_win.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_termination.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_thread_registry.o
.libs/libasan.lax/libsanitizer_co
mmon.a/sanitizer_tls_get_addr.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_unwind_linux_libcdep.o
.libs/libasan.lax/libsanitizer_common.a/sanitizer_unwind_win.o
.libs/libasan.lax/libsanitizer_common.a/sa
nitizer_win.o  .libs/libasan.lax/libsanitizer_lsan.a/lsan_common.o
.libs/libasan.lax/libsanitizer_lsan.a/lsan_common_linux.o
.libs/libasan.lax/libsanitizer_lsan.a/lsan_common_mac.o  
-L/workspace/srcdir/gcc_bui
ld/x86_64-apple-darwin14/libstdc++-v3/src/.libs
-L/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libstdc++-v3/src
-L/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs
-ldl -lpthre
ad ../../libstdc++-v3/src/.libs/libstdc++.dylib -lm    -install_name 
/workspace/destdir/x86_64-apple-darwin14/lib/libasan.6.dylib
-compatibility_version 7 -current_version 7.0 -Wl,-single_module               
[10:03:02] Undefined symbols for architecture x86_64:                           
[10:03:02]   "___lsan_default_suppressions", referenced from:                   
[10:03:02]       __ZN6__lsan22InitializeSuppressionsEv in lsan_common.o         
[10:03:02]   "___lsan_is_turned_off", referenced from:                          
[10:03:02]       __ZN6__lsanL13CheckForLeaksEv in lsan_common.o                 
[10:03:02]   "___sanitizer_free_hook", referenced from:                         
[10:03:02]      
__ZN6__asan9Allocator10DeallocateEPvmmPN11__sanitizer18BufferedStackTraceENS_9AllocTypeE
in asan_allocator.o                                                             
[10:03:02]      
__ZN6__asan9asan_freeEPvPN11__sanitizer18BufferedStackTraceENS_9AllocTypeE in
asan_allocator.o                                                                
[10:03:02]      
__ZN6__asan12asan_reallocEPvmPN11__sanitizer18BufferedStackTraceE in
asan_allocator.o                                                                
[10:03:02]   "___sanitizer_malloc_hook", referenced from:                       
[10:03:02]      
__ZN6__asan9Allocator8AllocateEmmPN11__sanitizer18BufferedStackTraceENS_9AllocTypeEb
in asan_allocator.o                                                             
[10:03:02]   "___sanitizer_symbolize_code", referenced from:                    
[10:03:02]      
__ZN11__sanitizer18InternalSymbolizer11SymbolizePCEmPNS_15SymbolizedStackE in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02]       __ZN11__sanitizer10Symbolizer12PlatformInitEv in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02]   "___sanitizer_symbolize_data", referenced from:
[10:03:02]      
__ZN11__sanitizer18InternalSymbolizer13SymbolizeDataEmPNS_8DataInfoE in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02]       __ZN11__sanitizer10Symbolizer12PlatformInitEv in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02]   "___sanitizer_symbolize_demangle", referenced from:
[10:03:02]       __ZN11__sanitizer18InternalSymbolizer8DemangleEPKc in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02]   "___sanitizer_symbolize_flush", referenced from:
[10:03:02]       __ZN11__sanitizer18InternalSymbolizer5FlushEv in
sanitizer_symbolizer_posix_libcdep.o
[10:03:02] ld: symbol(s) not found for architecture x86_64
[10:03:02] collect2: error: ld returned 1 exit status
[10:03:02] make[4]: *** [Makefile:577: libasan.la] Error 1
[10:03:02] make[4]: Leaving directory
'/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libsanitizer/asan'
[10:03:02] make[3]: *** [Makefile:531: all-recursive] Error 1
[10:03:02] make[3]: Leaving directory
'/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libsanitizer'
[10:03:02] make[2]: *** [Makefile:418: all] Error 2
[10:03:02] make[2]: Leaving directory
'/workspace/srcdir/gcc_build/x86_64-apple-darwin14/libsanitizer'
[10:03:02] make[1]: *** [Makefile:13570: all-target-libsanitizer] Error 2
[10:03:02] make[1]: Leaving directory '/workspace/srcdir/gcc_build'
[10:03:02] make: *** [Makefile:969: all] Error 2


Functions __lsan_is_turned_off and __lsan_default_suppressions are implemented
in
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libsanitizer/lsan/lsan_common.cpp;h=9e23aa9997ac0ee76e2fa51eb4981b16838ec6c5;hb=50bc9185c2821350f0b785d6e23a6e9dcde58466
only when !SANITIZER_SUPPORTS_WEAK_HOOKS is 1, but they are referenced
unconditionally in CheckForLeaks and InitializeSuppressions, in the same file. 
Since I'm using SDK 10.12, SANITIZER_SUPPORTS_WEAK_HOOKS is set to 1 at
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libsanitizer/sanitizer_common/sanitizer_internal_defs.h;h=d8f0540037d2435bc201a6cd7733fe4272f03519;hb=50bc9185c2821350f0b785d6e23a6e9dcde58466#l78
--- which I verified by placing an #error in that branch --- and so
!SANITIZER_SUPPORTS_WEAK_HOOKS will be 0, and the symbols __lsan_is_turned_off
and __lsan_default_suppressions are indeed not defined, as reported by the
error message.  Am I missing something?  How is this supposed to work?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
@ 2021-06-17 22:17 ` mose at gnu dot org
  2021-06-18 19:42 ` [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions mose at gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-17 22:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #1 from Mosè Giordano <mose at gnu dot org> ---
To add more information, the real problem seems to be that xgcc can't generate
weak symbols:


sandbox:${WORKSPACE}/srcdir/gcc_build # x86_64-apple-darwin14-nm
x86_64-apple-darwin14/libsanitizer/lsan/.libs/lsan_common.o | grep '___lsan'
00000000000018c0 T ___lsan_default_options
                 U ___lsan_default_suppressions
00000000000018a0 T ___lsan_disable
0000000000003440 T ___lsan_do_leak_check
0000000000003460 T ___lsan_do_recoverable_leak_check
00000000000018b0 T ___lsan_enable
00000000000014c0 T ___lsan_ignore_object
                 U ___lsan_default_suppressions
0000000000001580 T ___lsan_register_root_region
00000000000017c0 T ___lsan_unregister_root_region


___lsan_default_suppressions and ___lsan_default_suppressions should be weak,
instead they're undefined.  I can reproduce the same issue with this simpler
example:


sandbox:${WORKSPACE}/srcdir/gcc_build # /workspace/srcdir/gcc_build/./gcc/xgcc
-B/workspace/srcdir/gcc_build/./gcc -x c - << EOF
#include <stdio.h>
int __attribute__((weak)) func(int);
#if 0                               
int func(int a) { return 2 * a; }   
#endif                              
int main() {                        
    if (&func) {                        
        printf("Func implemented: %d\n", func(10));
    } else {                                       
        printf("Func not implemented\n");          
    }                                              
    return 0;                                      
}                                                  
EOF                                                
Undefined symbols for architecture x86_64:
  "_func", referenced from:
      _main in ccMDdanO.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
  2021-06-17 22:17 ` [Bug sanitizer/101111] " mose at gnu dot org
@ 2021-06-18 19:42 ` mose at gnu dot org
  2021-06-18 19:50 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-18 19:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #2 from Mosè Giordano <mose at gnu dot org> ---
I've gathered some more information.  In LLVM, libsanitizer uses
-Wl,-U,<symbol-name> to allow the macOS linker accept undefined symbols and
mimic ELF weak symbols, see
<https://github.com/llvm/llvm-project/blob/cbfb12469ba312c8ff513397b29bef470f151caa/compiler-rt/cmake/Modules/SanitizerUtils.cmake#L71>,
and
<https://github.com/llvm/llvm-project/blob/cbfb12469ba312c8ff513397b29bef470f151caa/compiler-rt/lib/lsan/weak_symbols.txt>
for the list of weak symbols in lsan.

GCC uses libtool checks to set these flags:
<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libsanitizer/configure;h=1d9ae59be6798555b7020a66e0f622ff8bf752cc;hb=50bc9185c2821350f0b785d6e23a6e9dcde58466#l8839>.
 This is a check on `$host_cpu-$host_os`, however I'm compiling a
cross-compiler (`build == host == x86_64-linux-musl`, `target ==
x86_64-apple-darwin`, I may have been inaccurate before), so shouldn't this
check use `$target_cpu-$target_os` instead?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
  2021-06-17 22:17 ` [Bug sanitizer/101111] " mose at gnu dot org
  2021-06-18 19:42 ` [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions mose at gnu dot org
@ 2021-06-18 19:50 ` pinskia at gcc dot gnu.org
  2021-06-18 22:46 ` mose at gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-18 19:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Mosè Giordano from comment #2) 
> GCC uses libtool checks to set these flags:
> <https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libsanitizer/configure;
> h=1d9ae59be6798555b7020a66e0f622ff8bf752cc;
> hb=50bc9185c2821350f0b785d6e23a6e9dcde58466#l8839>.  This is a check on
> `$host_cpu-$host_os`, however I'm compiling a cross-compiler (`build == host
> == x86_64-linux-musl`, `target == x86_64-apple-darwin`, I may have been
> inaccurate before), so shouldn't this check use `$target_cpu-$target_os`
> instead?

No host usage here is correct.  This is a (target) library which means the host
(and target) are set x86_64-apple-darwin and the build is set to
x86_64-linux-musl.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (2 preceding siblings ...)
  2021-06-18 19:50 ` pinskia at gcc dot gnu.org
@ 2021-06-18 22:46 ` mose at gnu dot org
  2021-06-18 23:24 ` mose at gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-18 22:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #4 from Mosè Giordano <mose at gnu dot org> ---
You're right, in `x86_64-apple-darwin14/libsanitizer/config.log` I can see that
`build == x86_64-linux-musl` and `host == target == x86_64-apple-darwin`, but
still, in `x86_64-apple-darwin14/libsanitizer` I don't see any reference to
linker flags like `-undefined dynamic_lookup`, `-U <symbol-name>`, `-undefined
suppress` or anything like that.  Maybe libsanitizer should use something
similar to `GCC_CHECK_ELF_STYLE_WEAKREF`
(<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=config/weakref.m4;h=ecb85672805882b330cac43e0fc12e7fe96aeec9;hb=HEAD>)
to actually use any these flags?  The undefined functions mentioned in the
error message use ELF-style weak symbols, but without appropriate flags the
macOS linker will complain.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (3 preceding siblings ...)
  2021-06-18 22:46 ` mose at gnu dot org
@ 2021-06-18 23:24 ` mose at gnu dot org
  2021-06-18 23:53 ` mose at gnu dot org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-18 23:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #5 from Mosè Giordano <mose at gnu dot org> ---
Ok, I finally found the culprit: `libsanitizer` does already have a way to add
`-Wl,-undefined,dynamic_lookup` to CXXFLAGS, but it uses a bashism:
<https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libsanitizer/configure.tgt;h=0ca5d9fd92464110d99a5da86b8de4378384e944;hb=HEAD#l68>.
 On Alpine Linux, the system where I'm doing the compilation, sh isn't bash and
appending to a string variable with += isn't valid.  Scavenging the compilation
log I found

/workspace/srcdir/gcc-11.1.0/libsanitizer/configure:
/workspace/srcdir/gcc-11.1.0/libsanitizer/configure.tgt: line 68:
EXTRA_CXXFLAGS+=-Wl,-undefined,dynamic_lookup: not found

If I replace

EXTRA_CXXFLAGS+="-Wl,-undefined,dynamic_lookup"

with

EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS} -Wl,-undefined,dynamic_lookup"

compilation of GCC is finally successful.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (4 preceding siblings ...)
  2021-06-18 23:24 ` mose at gnu dot org
@ 2021-06-18 23:53 ` mose at gnu dot org
  2021-07-19 20:33 ` mose at gnu dot org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-06-18 23:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #6 from Mosè Giordano <mose at gnu dot org> ---
Created attachment 51038
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51038&action=edit
Patch to fix the reported issue

Please find attached a patch to fix the reported issue.  I replaced the bashism
+= with simple string interpolation, to make it complaint with strict POSIX
shells.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (5 preceding siblings ...)
  2021-06-18 23:53 ` mose at gnu dot org
@ 2021-07-19 20:33 ` mose at gnu dot org
  2021-07-22 18:06 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-07-19 20:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #7 from Mosè Giordano <mose at gnu dot org> ---
Bump.  Is there any chance someone can review a one-line patch? :)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (6 preceding siblings ...)
  2021-07-19 20:33 ` mose at gnu dot org
@ 2021-07-22 18:06 ` marxin at gcc dot gnu.org
  2021-07-22 19:01 ` iains at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-07-22 18:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org
                 CC|                            |iains at gcc dot gnu.org
   Last reconfirmed|                            |2021-07-22

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
Sure, but I would like to first speak Iain who added the code.
What do you think about the patch?

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (7 preceding siblings ...)
  2021-07-22 18:06 ` marxin at gcc dot gnu.org
@ 2021-07-22 19:01 ` iains at gcc dot gnu.org
  2021-07-25 10:54 ` iains at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: iains at gcc dot gnu.org @ 2021-07-22 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #9 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #8)
> Sure, but I would like to first speak Iain who added the code.
> What do you think about the patch?

hm, sorry for introducing the bash-ism, the change LGTM but I would like to
bootstrap it on a native Darwin installation - should be able to fit that in in
the next day or do.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (8 preceding siblings ...)
  2021-07-22 19:01 ` iains at gcc dot gnu.org
@ 2021-07-25 10:54 ` iains at gcc dot gnu.org
  2021-07-25 10:56 ` mose at gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: iains at gcc dot gnu.org @ 2021-07-25 10:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #10 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Mosè Giordano from comment #6)
> Created attachment 51038 [details]
> Patch to fix the reported issue
> 
> Please find attached a patch to fix the reported issue.  I replaced the
> bashism += with simple string interpolation, to make it complaint with
> strict POSIX shells.

This is OK for master and back-ports from the Darwin perspective (I guess
Martin plans to deal with this since he has assigned the PR, but if he does not
have time, I can apply this for you if you don't have write access).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (9 preceding siblings ...)
  2021-07-25 10:54 ` iains at gcc dot gnu.org
@ 2021-07-25 10:56 ` mose at gnu dot org
  2021-08-03 11:25 ` cvs-commit at gcc dot gnu.org
  2021-08-03 11:25 ` marxin at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: mose at gnu dot org @ 2021-07-25 10:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #11 from Mosè Giordano <mose at gnu dot org> ---
> This is OK for master and back-ports from the Darwin perspective

Thanks for the review and confirmation!

> (I guess Martin plans to deal with this since he has assigned the PR, but if he does not have time, I can apply this for you if you don't have write access).

Yes, I don't have write access, so someone else will need to apply the patch
:-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (10 preceding siblings ...)
  2021-07-25 10:56 ` mose at gnu dot org
@ 2021-08-03 11:25 ` cvs-commit at gcc dot gnu.org
  2021-08-03 11:25 ` marxin at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-03 11:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:759f3854f0fdb4add2961bfafd1ee793f392f70a

commit r12-2686-g759f3854f0fdb4add2961bfafd1ee793f392f70a
Author: Mosè Giordano <mose@gnu.org>
Date:   Fri Jun 18 23:46:44 2021 +0000

    Fix bashism in `libsanitizer/configure.tgt'

    Appending to a string variable with `+=' is a bashism and does not work in
    strict POSIX shells like dash.  This results in the extra compilation flags
not
    to be set correctly.  This patch replaces the `+=' syntax with a simple
string
    interpolation to append to the `EXTRA_CXXFLAGS' variable.

    libsanitizer/ChangeLog

            PR sanitizer/101111
            * configure.tgt: Fix bashism in setting of `EXTRA_CXXFLAGS'.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions
  2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
                   ` (11 preceding siblings ...)
  2021-08-03 11:25 ` cvs-commit at gcc dot gnu.org
@ 2021-08-03 11:25 ` marxin at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-03 11:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101111

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #13 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks Iaian for testing, I've just pushed the commit.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-08-03 11:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 19:01 [Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS mose at gnu dot org
2021-06-17 22:17 ` [Bug sanitizer/101111] " mose at gnu dot org
2021-06-18 19:42 ` [Bug sanitizer/101111] xgcc cross-compiler for x86_64-apple-darwin in GCC 11.1 doesn't generate weak symbols, resulting in undefined reference to ___lsan_default_suppressions mose at gnu dot org
2021-06-18 19:50 ` pinskia at gcc dot gnu.org
2021-06-18 22:46 ` mose at gnu dot org
2021-06-18 23:24 ` mose at gnu dot org
2021-06-18 23:53 ` mose at gnu dot org
2021-07-19 20:33 ` mose at gnu dot org
2021-07-22 18:06 ` marxin at gcc dot gnu.org
2021-07-22 19:01 ` iains at gcc dot gnu.org
2021-07-25 10:54 ` iains at gcc dot gnu.org
2021-07-25 10:56 ` mose at gnu dot org
2021-08-03 11:25 ` cvs-commit at gcc dot gnu.org
2021-08-03 11:25 ` marxin at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).