LibC: Add libc.so

We now compile everything with -static flag so libc.a would be use
This commit is contained in:
Itamar 2020-10-16 12:57:15 +03:00 committed by Andreas Kling
parent 09ccdc697b
commit 58c583f584
Notes: sideshowbarker 2024-07-19 00:51:33 +09:00
5 changed files with 22 additions and 5 deletions

View file

@ -135,6 +135,16 @@ function(serenity_libc target_name fs_name)
serenity_generated_sources(${target_name})
endfunction()
function(serenity_libc_shared target_name fs_name)
serenity_install_headers("")
serenity_install_sources("Libraries/LibC")
add_library(${target_name} SHARED ${SOURCES})
install(TARGETS ${target_name} DESTINATION usr/lib)
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
target_link_directories(LibC PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
serenity_generated_sources(${target_name})
endfunction()
function(serenity_bin target_name)
add_executable(${target_name} ${SOURCES})
install(TARGETS ${target_name} RUNTIME DESTINATION bin)
@ -210,6 +220,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -g1 -fno-exceptions -fno-rtti -Wno-a
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -DSANITIZE_PTRS")
set(CMAKE_CXX_FLAGS_WITHOUT_STATIC ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
include_directories(Libraries/LibC)

View file

@ -3,7 +3,7 @@ set(SOURCES
../../Libraries/LibC/crt0_shared.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostartfiles -pie -fpic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_WITHOUT_STATIC} -nostartfiles -pie -fpic")
serenity_bin(DynamicObjectDemo)
target_link_libraries(DynamicObjectDemo SampleLib LibCShared)

View file

@ -3,7 +3,7 @@ set(SOURCES
lib.cpp
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -fpic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_WIHTOUT_STATIC} -nostdlib -fpic")
add_library(SampleLib SHARED ${SOURCES})
target_link_libraries(SampleLib LibCShared)

View file

@ -70,5 +70,8 @@ serenity_libc(LibC c)
target_link_libraries(LibC crt0)
add_dependencies(LibC LibM)
add_library(LibCShared SHARED ${SOURCES})
install(TARGETS LibCShared DESTINATION usr/lib)
set(SOURCES ${SOURCES} "crt0_shared.cpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
serenity_libc_shared(LibCShared c)
#add_library(LibCShared SHARED ${SOURCES})
#install(TARGETS LibCShared DESTINATION usr/lib)

View file

@ -22,9 +22,11 @@ int _start(int argc, char** argv, char** env)
__environ_is_malloced = false;
__libc_init();
_init();
// _init();
int status = main(argc, argv, environ);
return status;
}
}
void* __dso_handle = nullptr;