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

[libc] Use -nostdlibinc in the full build mode #97461

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libc/cmake/modules/CheckCompilerFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ check_cxx_compiler_flag("-ftrivial-auto-var-init=pattern" LIBC_CC_SUPPORTS_PATTE

# clang-6+, gcc-13+
check_cxx_compiler_flag("-nostdlib++" LIBC_CC_SUPPORTS_NOSTDLIBPP)

# clang-3.0+
check_c_compiler_flag("-nostdlibinc" LIBC_C_SUPPORTS_NOSTDLIBINC)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check_c_compiler_flag("-nostdlibinc" LIBC_C_SUPPORTS_NOSTDLIBINC)
check_c_compiler_flag("-nostdlibinc" LIBC_C_SUPPORTS_NOSTDLIBINC)

Isn't this a CXX project? Wouldn't make sense to require both C and CXX compiler to be set and match if so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

4 changes: 4 additions & 0 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function(_get_common_compile_options output_var flags)
list(APPEND compile_options "-DLIBC_FULL_BUILD")
# Only add -ffreestanding flag in full build mode.
list(APPEND compile_options "-ffreestanding")
# Manually disable all standard include paths.
if(LIBC_C_SUPPORTS_NOSTDLIBINC)
list(APPEND compile_options "-nostdlibinc")
endif()
endif()

if(LIBC_COMPILER_HAS_FIXED_POINT)
Expand Down
Loading