This is an archive of the discontinued LLVM Phabricator instance.

[libc] Use -nolibc -nostdlib++ -nostartfiles for hermetic test link.
ClosedPublic

Authored by sivachandra on May 2 2023, 12:53 PM.

Details

Summary

We previously used a more stricter -nostdlib option which was also removing
compiler-rt/libgcc.

Diff Detail

Event Timeline

sivachandra created this revision.May 2 2023, 12:53 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 2 2023, 12:53 PM
sivachandra requested review of this revision.May 2 2023, 12:53 PM
jhuber6 accepted this revision.May 2 2023, 12:54 PM

Does this also need to be applied to this?

foreach(lib LibcHermeticTest LibcHermeticTestMain)    
  target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include)    
  target_compile_options(${lib}    
      PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -ffreestanding -nostdlib -nostdlib++)    
endforeach()
This revision is now accepted and ready to land.May 2 2023, 12:54 PM

Does this also need to be applied to this?

foreach(lib LibcHermeticTest LibcHermeticTestMain)    
  target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include)    
  target_compile_options(${lib}    
      PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -ffreestanding -nostdlib -nostdlib++)    
endforeach()

Creating static/object libraries does not involve the linker so may be not required?

Does this also need to be applied to this?

foreach(lib LibcHermeticTest LibcHermeticTestMain)    
  target_include_directories(${lib} PRIVATE ${LIBC_BUILD_DIR}/include)    
  target_compile_options(${lib}    
      PRIVATE ${LIBC_HERMETIC_TEST_COMPILE_OPTIONS} -ffreestanding -nostdlib -nostdlib++)    
endforeach()

Creating static/object libraries does not involve the linker so may be not required?

I'm assuming this solution won't work on the GPU anyway since we don't have a compiler-rt there anyway. But for the CPU it should be fine as long as the final link has it.

Add -nostdlib++ also.

sivachandra retitled this revision from [libc] Replace -nostdlib with -nolibc and -nostartfiles for hermetic test link. to [libc] Use -nolibc -nostdlib++ -nostartfiles for hermetic test link..May 2 2023, 11:28 PM
sivachandra edited the summary of this revision. (Show Details)

-nostdlib++ is a clang-only flag, gcc fails with:

g++-12: error: unrecognized command-line option ‘-nostdlib++’; did you mean ‘-nostdlib’?