Skip to content
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

Compiling libc with SCUDO using gcc fails #60467

Closed
liam-clink opened this issue Feb 2, 2023 · 4 comments
Closed

Compiling libc with SCUDO using gcc fails #60467

liam-clink opened this issue Feb 2, 2023 · 4 comments
Assignees

Comments

@liam-clink
Copy link

liam-clink commented Feb 2, 2023

cmake invocation:

cmake -S ../llvm/ -B . -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;libc;lld;compiler-rt" -DLLVM_ENABLE_RUNTIMES="" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLIBCXX_USE_COMPILER_RT=YES -DLIBCXXABI_USE_COMPILER_RT=YES -DLLVM_USE_LINKER=lld -DLIBCXXABI_USE_LLVM_UNWINDER=YES -DLLVM_INSTALL_UTILS=On -DLLVM_LIBC_FULL_BUILD=ON -DLLVM_LIBC_INCLUDE_SCUDO=ON -DCOMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC=ON -DCOMPILER_RT_BUILD_GWP_ASAN=OFF -DCOMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=$HOME/llvm15_temp
[1/881] Linking CXX executable bin/libc-scudo-integration-test
FAILED: bin/libc-scudo-integration-test 
: && /home/liam/gcc-12.2.0/bin/g++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics    -pthreads projects/libc/test/integration/scudo/CMakeFiles/libc-scudo-integration-test.dir/integration_test.cpp.o -o bin/libc-scudo-integration-test  projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a && cd /home/liam/Documents/GitHub/llvm-project/build/projects/libc/test/integration/scudo && /home/liam/Documents/GitHub/llvm-project/build/bin/libc-scudo-integration-test
g++: error: unrecognized command-line option '-pthreads'; did you mean '-pthread'?
[2/881] Linking CXX executable bin/libc-gwp-asan-uaf-should-crash
FAILED: bin/libc-gwp-asan-uaf-should-crash 
: && /home/liam/gcc-12.2.0/bin/g++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics    -pthreads projects/libc/test/integration/scudo/CMakeFiles/libc-gwp-asan-uaf-should-crash.dir/gwp_asan_should_crash.cpp.o -o bin/libc-gwp-asan-uaf-should-crash  projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a && :
g++: error: unrecognized command-line option '-pthreads'; did you mean '-pthread'?
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 2, 2023

@llvm/issue-subscribers-libc

@liam-clink
Copy link
Author

liam-clink commented Feb 2, 2023

I just tried the same thing except with Clang instead of GCC and I still get an error in linking libc-gwp-asan-uaf-should-crash

[3542/5538] Linking CXX executable bin/libc-gwp-asan-uaf-should-crash
FAILED: bin/libc-gwp-asan-uaf-should-crash 
: && /home/liam/llvm-15.0.6/bin/clang++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics    -pthreads projects/libc/test/integration/scudo/CMakeFiles/libc-gwp-asan-uaf-should-crash.dir/gwp_asan_should_crash.cpp.o -o bin/libc-gwp-asan-uaf-should-crash  projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a && :
ld.lld: error: undefined symbol: __llvmlibc_errno
>>> referenced by wrappers_c.inc:0 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.inc:0)
>>>               wrappers_c.cpp.o:(calloc) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced by wrappers_c_checks.h:25 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c_checks.h:25)
>>>               wrappers_c.cpp.o:(malloc) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced by wrappers_c.inc:99 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_c.inc:99)
>>>               wrappers_c.cpp.o:(memalign) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced 7 more times

ld.lld: error: undefined symbol: __llvm_libc_syscall
>>> referenced by linux.cpp:117 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:117)
>>>               linux.cpp.o:(scudo::HybridMutex::lockSlow()) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced by linux.cpp:126 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:126)
>>>               linux.cpp.o:(scudo::HybridMutex::unlock()) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced by linux.cpp:151 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:151)
>>>               linux.cpp.o:(scudo::getThreadID()) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a
>>> referenced 1 more times

ld.lld: error: undefined symbol: __sched_getcpucount
>>> referenced by linux.cpp:144 (/home/liam/Documents/GitHub/llvm-project/compiler-rt/lib/scudo/standalone/linux.cpp:144)
>>>               linux.cpp.o:(scudo::getNumberOfCPUs()) in archive projects/libc/test/integration/scudo/liblibc_for_scudo_integration_test.a

michaelrj-google added a commit that referenced this issue Mar 2, 2023
The integration tests were failing to build under GCC due to missing
compile options for using LLVM's libc++ and compiler-rt.

This should unblock #60467

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D145128
@michaelrj-google
Copy link
Contributor

This issue should be fixed by the above patch, if it isn't feel free to file a new bug.

gnoliyil pushed a commit to gnoliyil/fuchsia that referenced this issue Jan 27, 2024
…s when using gcc

The integration tests were failing to build under GCC due to missing
compile options for using LLVM's libc++ and compiler-rt.

This should unblock llvm/llvm-project#60467

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D145128

GitOrigin-RevId: 4ac92c1cc118580b71ae9f3e59f6201401654cbc
Original-Revision: ff19762a2ae7f26418c2b1fc4c69c954dd86fd86
Roller-URL: https://ci.chromium.org/b/8787691901795362673
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I2e00e77ecac57411248828345b79655717bfd3a9
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/813259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@EugeneZelenko @liam-clink @llvmbot @michaelrj-google and others