Skip to content
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
7 changes: 6 additions & 1 deletion flang-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
# Check whether -fno-lto is supported.
check_cxx_compiler_flag(-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG)

# Check whether -Wl,--as-needed is supported.
check_linker_flag(C "-Wl,--as-needed" LINKER_SUPPORTS_AS_NEEDED)
if (LINKER_SUPPORTS_AS_NEEDED)
set(LINKER_AS_NEEDED_OPT "-Wl,--as-needed")
endif()

# Different platform may have different name for the POSIX thread library.
# For example, libpthread.a on AIX. Search for it as it is needed when
# building the shared flang_rt.runtime.so.
Expand Down Expand Up @@ -295,7 +301,6 @@ elseif (FLANG_RT_GCC_RESOURCE_DIR)
endif ()



#####################
# Build Preparation #
#####################
Expand Down
11 changes: 11 additions & 0 deletions flang-rt/cmake/modules/AddFlangRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ function (add_flangrt_library name)
else ()
set_target_properties(${tgtname} PROPERTIES FOLDER "Flang-RT/Libraries")
endif ()

# flang-rt libraries must not depend on libc++/libstdc++,
# so set the linker language to C to avoid the unnecessary
# library dependence. Note that libc++/libstdc++ may still
# come through CMAKE_CXX_IMPLICIT_LINK_LIBRARIES.
set_target_properties(${tgtname} PROPERTIES LINKER_LANGUAGE C)
# Use --as-needed to avoid unnecessary dependencies.
if (LINKER_AS_NEEDED_OPT)
set_property(TARGET ${tgtname} APPEND_STRING PROPERTY
LINK_FLAGS "${LINKER_AS_NEEDED_OPT}")
endif()
endforeach ()

# Define how to compile and link the library.
Expand Down