Skip to content

Commit

Permalink
lld: Enable building C projects without crt files
Browse files Browse the repository at this point in the history
crt[begin|end].o files are used for C++ projects. While they usually exist in
GCC, they may or may not exist in LLVM builds that don't rely on GCC toolchain,
and typically require a separate (optional) compiler-rt/cxx library to build.

This commit allows building projects without crt[begin|end].o files if they
do not exist.
  • Loading branch information
heshamelmatary committed Jan 15, 2024
1 parent df31d5a commit 70ca15a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmake-tool/helpers/environment_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ macro(find_libgcc_files)
# find the compilers crtbegin and crtend files
gcc_print_file_name(CRTBeginFile crtbegin.o)
gcc_print_file_name(CRTEndFile crtend.o)

# Empty crt files variables if not found in the current toolchain.
# This should allow building/linking without cxx crt files (e.g., just C projects).
if("${CRTBeginFile}" STREQUAL "crtbegin.o" OR ${CRTEndFile} STREQUAL "crtend.o")
message(WARNING "cxx: no crt object files found.")
set(CRTBeginFile "")
set(CRTEndFile "")
endif()

gcc_print_file_name(libgcc_eh libgcc_eh.a)
set(libgcc "-lgcc")
if(NOT "${libgcc_eh}" STREQUAL "libgcc_eh.a")
Expand Down

0 comments on commit 70ca15a

Please sign in to comment.