mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Everywhere: Explicitly link all binaries against the LibC target
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
This commit is contained in:
parent
39fca21e11
commit
7834e26ddb
Notes:
sideshowbarker
2024-07-17 04:54:41 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/7834e26ddb Pull-request: https://github.com/SerenityOS/serenity/pull/15746 Issue: https://github.com/SerenityOS/serenity/issues/14376
39 changed files with 42 additions and 33 deletions
|
@ -2,6 +2,15 @@
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/serenity_components.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/code_generators.cmake)
|
||||
|
||||
function(serenity_set_implicit_links target_name)
|
||||
# Make sure that CMake is aware of the implicit LibC dependency, and ensure
|
||||
# that we are choosing the correct and updated LibC.
|
||||
# The latter is a problem with Clang especially, since we might have the
|
||||
# slightly outdated stub in the sysroot, but have not yet installed the freshly
|
||||
# built LibC.
|
||||
target_link_libraries(${target_name} LibC)
|
||||
endfunction()
|
||||
|
||||
function(serenity_install_headers target_name)
|
||||
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
foreach(header ${headers})
|
||||
|
@ -43,6 +52,7 @@ if (NOT COMMAND serenity_lib)
|
|||
install(TARGETS ${target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
serenity_set_implicit_links(${target_name})
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
|
@ -56,6 +66,7 @@ if (NOT COMMAND serenity_lib_static)
|
|||
install(TARGETS ${target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
serenity_set_implicit_links(${target_name})
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
|
@ -80,6 +91,7 @@ if (NOT COMMAND serenity_bin)
|
|||
set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
install(TARGETS ${target_name} RUNTIME DESTINATION bin OPTIONAL)
|
||||
serenity_generated_sources(${target_name})
|
||||
serenity_set_implicit_links(${target_name})
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
|
@ -96,6 +108,7 @@ function(serenity_test test_src sub_dir)
|
|||
add_executable(${test_name} ${TEST_SOURCES})
|
||||
add_dependencies(ComponentTests ${test_name})
|
||||
set_target_properties(${test_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
serenity_set_implicit_links(${test_name})
|
||||
target_link_libraries(${test_name} LibTest LibCore)
|
||||
foreach(lib ${SERENITY_TEST_LIBS})
|
||||
target_link_libraries(${test_name} ${lib})
|
||||
|
|
|
@ -26,6 +26,7 @@ foreach(source IN LISTS TEST_SOURCES)
|
|||
get_filename_component(test_name "${source}" NAME_WE)
|
||||
add_executable("${test_name}" "${source}")
|
||||
target_link_libraries("${test_name}" LibCore)
|
||||
serenity_set_implicit_links("${test_name}")
|
||||
install(TARGETS "${test_name}" RUNTIME DESTINATION usr/Tests/Kernel/Legacy)
|
||||
endforeach()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ macro(add_dlopen_lib NAME FUNCTION)
|
|||
target_compile_definitions(${NAME} PRIVATE -DFUNCTION=${FUNCTION})
|
||||
# LibLine is not special, just an "external" dependency
|
||||
target_link_libraries(${NAME} LibLine)
|
||||
serenity_set_implicit_links(${NAME})
|
||||
# Avoid execution by the test runner
|
||||
install(TARGETS ${NAME}
|
||||
DESTINATION usr/Tests/LibELF
|
||||
|
|
|
@ -18,6 +18,7 @@ serenity_component(
|
|||
)
|
||||
add_executable(test262-runner test262-runner.cpp)
|
||||
target_link_libraries(test262-runner LibJS LibCore)
|
||||
serenity_set_implicit_links(test262-runner)
|
||||
link_with_locale_data(test262-runner)
|
||||
install(TARGETS test262-runner RUNTIME DESTINATION bin OPTIONAL)
|
||||
|
||||
|
@ -27,4 +28,5 @@ serenity_component(
|
|||
)
|
||||
add_executable(test-test262 test-test262.cpp)
|
||||
target_link_libraries(test-test262 LibMain LibCore)
|
||||
serenity_set_implicit_links(test-test262)
|
||||
install(TARGETS test-test262 RUNTIME DESTINATION bin OPTIONAL)
|
||||
|
|
|
@ -8,5 +8,6 @@ foreach(source IN LISTS TEST_SOURCES)
|
|||
get_filename_component(test_name "${source}" NAME_WE)
|
||||
add_executable("${test_name}" "${source}")
|
||||
target_link_libraries("${test_name}" LibCore)
|
||||
serenity_set_implicit_links("${test_name}")
|
||||
install(TARGETS "${test_name}" RUNTIME DESTINATION usr/Tests/UserEmulator)
|
||||
endforeach()
|
||||
|
|
|
@ -9,7 +9,7 @@ set(GENERATED_SOURCES
|
|||
LanguageServerEndpoint.h)
|
||||
|
||||
serenity_lib(LibLanguageServer languageserver)
|
||||
target_link_libraries(LibLanguageServer LibCodeComprehension LibC)
|
||||
target_link_libraries(LibLanguageServer LibCodeComprehension)
|
||||
|
||||
add_subdirectory(Cpp)
|
||||
add_subdirectory(Shell)
|
||||
|
|
|
@ -6,4 +6,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCards cards)
|
||||
target_link_libraries(LibCards LibC LibCore LibConfig LibGUI)
|
||||
target_link_libraries(LibCards LibCore LibConfig LibGUI)
|
||||
|
|
|
@ -5,4 +5,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibChess chess)
|
||||
target_link_libraries(LibChess LibC LibCore)
|
||||
target_link_libraries(LibChess LibCore)
|
||||
|
|
|
@ -4,7 +4,6 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCodeComprehension codecomprehension)
|
||||
target_link_libraries(LibCodeComprehension LibC)
|
||||
|
||||
add_subdirectory(Cpp)
|
||||
add_subdirectory(Shell)
|
||||
|
|
|
@ -3,7 +3,7 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCppComprehension cppcomprehension)
|
||||
target_link_libraries(LibCppComprehension LibCodeComprehension LibC)
|
||||
target_link_libraries(LibCppComprehension LibCodeComprehension)
|
||||
|
||||
serenity_component(
|
||||
CppComprehensionTests
|
||||
|
|
|
@ -3,4 +3,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibShellComprehension shellcomprehension)
|
||||
target_link_libraries(LibShellComprehension LibCodeComprehension LibC)
|
||||
target_link_libraries(LibShellComprehension LibCodeComprehension)
|
||||
|
|
|
@ -7,4 +7,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCompress compress)
|
||||
target_link_libraries(LibCompress LibC LibCrypto)
|
||||
target_link_libraries(LibCompress LibCrypto)
|
||||
|
|
|
@ -45,4 +45,4 @@ if (NOT ANDROID AND NOT WIN32)
|
|||
endif()
|
||||
|
||||
serenity_lib(LibCore core)
|
||||
target_link_libraries(LibCore LibC LibCrypt LibSystem)
|
||||
target_link_libraries(LibCore LibCrypt LibSystem)
|
||||
|
|
|
@ -5,4 +5,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCoredump coredump)
|
||||
target_link_libraries(LibCoredump LibC LibCompress LibCore LibDebug)
|
||||
target_link_libraries(LibCoredump LibCompress LibCore LibDebug)
|
||||
|
|
|
@ -9,4 +9,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCpp cpp)
|
||||
target_link_libraries(LibCpp LibC LibSyntax LibDiff)
|
||||
target_link_libraries(LibCpp LibSyntax LibDiff)
|
||||
|
|
|
@ -11,4 +11,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCrypt crypt)
|
||||
target_link_libraries(LibCrypt LibC LibCryptSHA2)
|
||||
target_link_libraries(LibCrypt LibCryptSHA2)
|
||||
|
|
|
@ -33,4 +33,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibCrypto crypto)
|
||||
target_link_libraries(LibCrypto LibC LibCore)
|
||||
target_link_libraries(LibCrypto LibCore)
|
||||
|
|
|
@ -5,4 +5,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibDNS dns)
|
||||
target_link_libraries(LibDNS LibC LibIPC)
|
||||
target_link_libraries(LibDNS LibIPC)
|
||||
|
|
|
@ -14,4 +14,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibDebug debug)
|
||||
target_link_libraries(LibDebug LibC LibRegex)
|
||||
target_link_libraries(LibDebug LibRegex)
|
||||
|
|
|
@ -4,4 +4,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibDeviceTree DeviceTree)
|
||||
target_link_libraries(LibDeviceTree LibC LibCore)
|
||||
target_link_libraries(LibDeviceTree LibCore)
|
||||
|
|
|
@ -6,4 +6,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibDiff diff)
|
||||
target_link_libraries(LibDiff LibC)
|
||||
|
|
|
@ -8,5 +8,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibEDID edid)
|
||||
target_link_libraries(LibEDID LibC)
|
||||
target_compile_definitions(LibEDID PRIVATE ENABLE_PNP_IDS_DATA=$<BOOL:${ENABLE_PNP_IDS_DOWNLOAD}>)
|
||||
|
|
|
@ -5,4 +5,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibIPC ipc)
|
||||
target_link_libraries(LibIPC LibC LibCore)
|
||||
target_link_libraries(LibIPC LibCore)
|
||||
|
|
|
@ -7,4 +7,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibLine line)
|
||||
target_link_libraries(LibLine LibC LibCore)
|
||||
target_link_libraries(LibLine LibCore)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib_static(LibMain main)
|
||||
target_link_libraries(LibMain LibC)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibPCIDB pcidb)
|
||||
target_link_libraries(LibPCIDB LibC)
|
||||
|
|
|
@ -19,4 +19,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibPDF pdf)
|
||||
target_link_libraries(LibPDF LibC LibCore LibIPC LibGfx LibTextCodec LibCrypto)
|
||||
target_link_libraries(LibPDF LibCore LibIPC LibGfx LibTextCodec LibCrypto)
|
||||
|
|
|
@ -11,4 +11,4 @@ if(SERENITYOS)
|
|||
endif()
|
||||
|
||||
serenity_lib(LibRegex regex)
|
||||
target_link_libraries(LibRegex LibC LibCore LibUnicode)
|
||||
target_link_libraries(LibRegex LibCore LibUnicode)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibSyntax syntax)
|
||||
target_link_libraries(LibSyntax LibC)
|
||||
|
|
|
@ -6,7 +6,6 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibTest test)
|
||||
target_link_libraries(LibTest LibC)
|
||||
|
||||
add_library(LibTestMain OBJECT TestMain.cpp)
|
||||
add_library(JavaScriptTestRunnerMain OBJECT JavaScriptTestRunnerMain.cpp)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibTextCodec textcodec)
|
||||
target_link_libraries(LibTextCodec LibC)
|
||||
|
|
|
@ -4,4 +4,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibThreading threading)
|
||||
target_link_libraries(LibThreading LibC LibCore)
|
||||
target_link_libraries(LibThreading LibCore)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibUSBDB usbdb)
|
||||
target_link_libraries(LibUSBDB LibC)
|
||||
|
|
|
@ -11,4 +11,4 @@ set(GENERATED_SOURCES
|
|||
|
||||
generate_state_machine(StateMachine.txt EscapeSequenceStateMachine.h)
|
||||
serenity_lib(LibVT vt)
|
||||
target_link_libraries(LibVT LibC LibCore LibGUI LibGfx LibDesktop LibConfig)
|
||||
target_link_libraries(LibVT LibCore LibGUI LibGfx LibDesktop LibConfig)
|
||||
|
|
|
@ -8,4 +8,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibWasm wasm)
|
||||
target_link_libraries(LibWasm LibC LibCore)
|
||||
target_link_libraries(LibWasm LibCore)
|
||||
|
|
|
@ -3,4 +3,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibX86 x86)
|
||||
target_link_libraries(LibX86 LibC)
|
||||
|
|
|
@ -4,4 +4,3 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibXML xml)
|
||||
target_link_libraries(LibXML LibC)
|
||||
|
|
|
@ -9,4 +9,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_bin(CrashDaemon)
|
||||
target_link_libraries(CrashDaemon LibC LibCompress LibCore LibCoredump LibMain)
|
||||
target_link_libraries(CrashDaemon LibCompress LibCore LibCoredump LibMain)
|
||||
|
|
|
@ -41,12 +41,14 @@ foreach(CMD_SRC ${CMD_SOURCES})
|
|||
if (CMD_NAME IN_LIST SPECIAL_TARGETS)
|
||||
add_executable(${TARGET_NAME} ${CMD_SRC})
|
||||
target_link_libraries(${TARGET_NAME} LibCore LibMain)
|
||||
serenity_set_implicit_links(${TARGET_NAME})
|
||||
install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION bin)
|
||||
install(CODE "file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME}-bin ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME})")
|
||||
else()
|
||||
add_executable(${CMD_NAME} ${CMD_SRC})
|
||||
set_target_properties(${CMD_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
target_link_libraries(${CMD_NAME} LibCore)
|
||||
serenity_set_implicit_links(${TARGET_NAME})
|
||||
install(TARGETS ${CMD_NAME} RUNTIME DESTINATION bin OPTIONAL)
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
Loading…
Reference in a new issue