Skip to content

Commit

Permalink
LibC+LibSanitizer+LibSystem: Remove static libc
Browse files Browse the repository at this point in the history
Static libc on Serenity is broken in a more than one way and requires a
lot of patches to bring it to a usable and useful state. Therefore,
instead of keeping it around (and breaking even more) during the
upcoming libc build refactor, let's just delete it.
  • Loading branch information
DanShaders authored and ADKaster committed May 7, 2024
1 parent 028f979 commit 4439b4a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
25 changes: 0 additions & 25 deletions Userland/Libraries/LibC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")

# Note: We link all these against NoCoverage so that we don't break ports by requiring coverage symbols
# in runtime/startup objects.
# Since all native serenity applications use dynamic libraries, prevent coverage on libc.a as well

add_library(crt0 STATIC crt0.cpp)
add_dependencies(crt0 install_libc_headers)
Expand Down Expand Up @@ -167,35 +166,11 @@ endif()

set_source_files_properties(ssp.cpp PROPERTIES COMPILE_FLAGS "-fno-stack-protector")

add_library(LibCStaticWithoutDeps STATIC ${SOURCES})
target_link_libraries(LibCStaticWithoutDeps PUBLIC ssp LibTimeZone PRIVATE NoCoverage)
add_dependencies(LibCStaticWithoutDeps LibSystem LibUBSanitizer)

add_custom_target(LibCStatic
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibCStaticWithoutDeps>
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibSystemStatic>
COMMAND ${CMAKE_AR} -x $<TARGET_FILE:LibUBSanitizerStatic>
COMMAND ${CMAKE_AR} -rcs ${CMAKE_CURRENT_BINARY_DIR}/libc.a *.o
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS LibCStaticWithoutDeps LibSystemStatic LibUBSanitizerStatic
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libc.a DESTINATION ${CMAKE_INSTALL_PREFIX}/usr/lib/)
file(GLOB TEMP_OBJ_FILES ${CMAKE_CURRENT_BINARY_DIR}/*.o)
set_property(
TARGET LibCStatic
APPEND
PROPERTY ADDITIONAL_CLEAN_FILES ${TEMP_OBJ_FILES}
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nolibc")
serenity_libc(LibC c)
add_dependencies(LibC crti crt0 crt0_shared crtn install_libc_headers)
target_link_libraries(LibC PRIVATE LibSystem LibTimeZone)

# We mark LibCStatic as a dependency of LibC because this triggers the build of the LibCStatic target
add_dependencies(LibC LibCStatic)

# Provide a linker script instead of various other libraries that tells everything to link against LibC.
file(WRITE "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libpthread.so" "INPUT(libc.so)")
file(WRITE "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libdl.so" "INPUT(libc.so)")
Expand Down
4 changes: 0 additions & 4 deletions Userland/Libraries/LibSanitizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ set_source_files_properties(../LibC/ssp_nonshared.cpp PROPERTIES COMPILE_FLAGS "
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
serenity_libc(LibUBSanitizer ubsan)
add_dependencies(LibUBSanitizer install_libc_headers)

add_library(LibUBSanitizerStatic STATIC ${SOURCES})
add_dependencies(LibUBSanitizerStatic install_libc_headers)
target_link_libraries(LibUBSanitizerStatic PRIVATE NoCoverage)
5 changes: 0 additions & 5 deletions Userland/Libraries/LibSystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
serenity_libc(LibSystem system)
add_dependencies(LibSystem install_libc_headers)
target_include_directories(LibSystem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_library(LibSystemStatic STATIC ${SOURCES})
add_dependencies(LibSystemStatic install_libc_headers)
target_include_directories(LibSystemStatic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(LibSystemStatic PRIVATE NoCoverage)

0 comments on commit 4439b4a

Please sign in to comment.