[Bug libcc1/104799] Header issue with x86_64-linux-musl based cross-compiler

2022-03-05 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104799

--- Comment #2 from Mosè Giordano  ---
Created attachment 52568
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52568=edit
Patch for poisoned calloc on Musl systems

Following the example of
https://git.alpinelinux.org/aports/tree/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch,
reported in https://bugs.gentoo.org/828580, I wrote the attached patch for
libcc1, which seems to solve the issue for me.

[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-07-25 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #11 from Mosè Giordano  ---
> 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
:-)

[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-07-19 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #7 from Mosè Giordano  ---
Bump.  Is there any chance someone can review a one-line patch? :)

[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-18 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #6 from Mosè Giordano  ---
Created attachment 51038
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51038=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.

[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-18 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #5 from Mosè Giordano  ---
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:
.
 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.

[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-18 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #4 from Mosè Giordano  ---
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 `, `-undefined
suppress` or anything like that.  Maybe libsanitizer should use something
similar to `GCC_CHECK_ELF_STYLE_WEAKREF`
()
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.

[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-18 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #2 from Mosè Giordano  ---
I've gathered some more information.  In LLVM, libsanitizer uses
-Wl,-U, to allow the macOS linker accept undefined symbols and
mimic ELF weak symbols, see
,
and

for the list of weak symbols in lsan.

GCC uses libtool checks to set these flags:
.
 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?

[Bug sanitizer/101111] Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS

2021-06-17 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #1 from Mosè Giordano  ---
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'
18c0 T ___lsan_default_options
 U ___lsan_default_suppressions
18a0 T ___lsan_disable
3440 T ___lsan_do_leak_check
3460 T ___lsan_do_recoverable_leak_check
18b0 T ___lsan_enable
14c0 T ___lsan_ignore_object
 U ___lsan_default_suppressions
1580 T ___lsan_register_root_region
17c0 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 
int __attribute__((weak)) func(int);
#if 0   
int func(int a) { return 2 * a; }   
#endif  
int main() {
if () {
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

[Bug sanitizer/101111] New: Undefined reference to ___lsan_default_suppressions when compiling GCC 11.1 for x86_64 macOS

2021-06-17 Thread mose at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

Bug ID: 10
   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