Attempt to link more libraries using two-level namespace

This commit is contained in:
Sergey Bugaev 2020-10-11 19:05:00 +03:00
parent 90f72585d6
commit aae3407ee3
10 changed files with 103 additions and 97 deletions

View File

@ -25,7 +25,7 @@ function(add_framework name)
else (FRAMEWORK_IOSSUPPORT)
set(sys_library_dir "System/Library")
endif (FRAMEWORK_IOSSUPPORT)
if(DEFINED FRAMEWORK_PARENT)
if(NOT DEFINED FRAMEWORK_PARENT_VERSION)
# 99% of the time it's version A
@ -57,7 +57,7 @@ function(add_framework name)
endif (FRAMEWORK_FAT)
endif (FRAMEWORK_CIRCULAR_DEPENDENCIES)
set_property(TARGET ${my_name} PROPERTY DYLIB_INSTALL_NAME ${DYLIB_INSTALL_NAME})
if (FRAMEWORK_CURRENT_VERSION)

View File

@ -13,7 +13,7 @@ add_definitions(-D_LIBCPP_NO_EXCEPTIONS=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-availability -include ${CMAKE_SOURCE_DIR}/src/duct/include/CrashReporterClient.h")
set(CMAKE_SHARED_LINKER_FLAGS_SAVED "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-bind_at_load -Wl,-flat_namespace -Wl,-undefined,suppress")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib")
add_definitions(-DHAVE_STDINT_H=1)
@ -60,7 +60,7 @@ add_circular(system_dyld FAT
dyld3/ClosureBuilder.cpp
dyld3/Closure.cpp
dyld3/ClosureFileSystemPhysical.cpp
dyld3/ClosurePrinter.cpp
#dyld3/ClosurePrinter.cpp
dyld3/ClosureWriter.cpp
dyld3/Diagnostics.cpp
dyld3/shared-cache/DyldSharedCache.cpp
@ -74,9 +74,16 @@ add_circular(system_dyld FAT
dyld3/PathOverrides.cpp
dyld3/Tracing.cpp
SIBLINGS
system_c system_kernel compiler_rt platform
DEPENDENCIES
UPWARD
system_c
system_kernel
system_malloc
system_blocks
system_pthread
system_sandbox
libdispatch_shared
compiler_rt
platform
launch
)
set_target_properties(system_dyld PROPERTIES

View File

@ -10,7 +10,7 @@ include_directories(
add_definitions(-w -nostdinc)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks -include ${CMAKE_SOURCE_DIR}/kernel-include/sys/fileport.h -ggdb")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-flat_namespace -Wl,-undefined,suppress")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib")
mig(job.defs)
mig(helper.defs)
@ -30,9 +30,14 @@ add_circular(launch FAT
SIBLINGS
system_c
system_kernel
system_dyld
DEPENDENCIES
system_pthread
system_malloc
platform
libdispatch_shared
compiler_rt
)
#target_link_libraries(launch PRIVATE system_c system_kernel)
#make_fat(launch)
install(TARGETS launch DESTINATION libexec/darling/usr/lib/system)

View File

@ -70,7 +70,6 @@ add_circular(system_info FAT
xpc
compiler_rt
launch
DEPENDENCIES
resolv-darwin
)
#target_link_libraries(system_info PRIVATE system_c resolv-darwin system_dyld system_blocks libdispatch_shared system_notify platform)

View File

@ -40,10 +40,11 @@ add_circular(system_malloc FAT
${libmalloc_sources}
SIBLINGS
system_kernel
system_c
platform
system_dyld
compiler_rt
UPWARD
system_c
)
install(TARGETS system_malloc DESTINATION libexec/darling/usr/lib/system)

View File

@ -30,7 +30,7 @@ set(DYLIB_INSTALL_NAME "/usr/lib/system/libsystem_notify.dylib")
add_circular(system_notify FAT
SOURCES
${notify_sources}
SIBLINGS
DEPENDENCIES
system_c
system_kernel
system_blocks
@ -43,7 +43,6 @@ add_circular(system_notify FAT
system_asl
)
#target_link_libraries(system_notify system_c system_kernel system_blocks libdispatch_shared launch system_dyld system_malloc system_pthread)
#make_fat(system_notify)
add_darling_executable(notifyutil notifyutil/notifyutil.c)

View File

@ -15,7 +15,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dnsinfo)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks -nostdinc -DUSE__RES_9")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,-flat_namespace -Wl,-undefined,suppress")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib")
# Hide warnings
add_definitions(
@ -58,10 +58,22 @@ set(resolv_sources
set(DYLIB_COMPAT_VERSION "1.0.0")
set(DYLIB_CURRENT_VERSION "1.0.0")
set(DYLIB_INSTALL_NAME "/usr/lib/libresolv.9.dylib")
add_darling_library(resolv-darwin SHARED ${resolv_sources})
add_circular(resolv-darwin FAT
SOURCES
${resolv_sources}
SIBLINGS
system_info
DEPENDENCIES
system_pthread
system_malloc
system_c
system_kernel
system_dnssd
system_notify
system_dyld
)
set_target_properties(resolv-darwin PROPERTIES OUTPUT_NAME "resolv.9")
make_fat(resolv-darwin)
#target_link_libraries(resolv-darwin PRIVATE system)
InstallSymlink("libresolv.9.dylib" "${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libresolv.dylib")
install(TARGETS resolv-darwin DESTINATION libexec/darling/usr/lib)

View File

@ -8,7 +8,7 @@ add_darling_library(sandbox_not_system SHARED
src/sandbox.c
)
set_target_properties(sandbox_not_system PROPERTIES OUTPUT_NAME sandbox.1)
make_fat(sandbox)
make_fat(sandbox_not_system)
target_link_libraries(sandbox_not_system system)
install(TARGETS sandbox_not_system DESTINATION libexec/darling/usr/lib)
InstallSymlink(libsandbox.1.dylib ${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib/libsandbox.dylib)

View File

@ -32,86 +32,62 @@ set(libsystem_sources
)
set(DYLIB_INSTALL_NAME "/usr/lib/libSystem.B.dylib")
add_circular(system FAT
SOURCES
${libsystem_sources}
OBJECTS
$<TARGET_OBJECTS:kqueue>
SIBLINGS
system_malloc
add_darling_library(system
${libsystem_sources}
$<TARGET_OBJECTS:kqueue>
)
target_link_libraries(system PRIVATE
sandbox
system_quarantine
removefile
system_copyfile
system_coreservices
system_coretls
system_malloc
system_c
system_kernel
system_trace
keymgr
system_m
system_info
system_notify
libdispatch_shared
launch
compiler_rt
unwind
system_dyld
macho
system_pthread
platform
system_asl
system_duct
system_blocks
xpc
corecrypto
commonCrypto
system_dnssd
system_networkextension
function(libsystem_reexport)
while(ARGN)
list(GET ARGN 0 sublib)
list(GET ARGN 1 sublib_path)
add_dependencies(system ${sublib})
set_property(TARGET system APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,-reexport_library -Wl,${CMAKE_BINARY_DIR}/${sublib_path} ")
list(REMOVE_AT ARGN 0 1)
endwhile(ARGN)
endfunction(libsystem_reexport)
libsystem_reexport(
system_sandbox src/sandbox/libsystem_sandbox.dylib
system_quarantine src/quarantine/libquarantine.dylib
removefile src/libremovefile/libremovefile.dylib
system_copyfile src/copyfile/libcopyfile.dylib
system_coreservices src/libsystem_coreservices/libsystem_coreservices.dylib
system_coretls src/external/coretls/libsystem_coretls.dylib
system_malloc src/libmalloc/libsystem_malloc.dylib
system_c src/libc/libsystem_c.dylib
system_kernel src/kernel/libsystem_kernel.dylib
system_trace src/external/libtrace/libsystem_trace.dylib
keymgr src/keymgr/libkeymgr.dylib
system_m src/libm/libsystem_m.dylib
system_info src/libinfo/libsystem_info.dylib
system_notify src/libnotify/libsystem_notify.dylib
libdispatch_shared src/external/libdispatch/libdispatch.dylib
launch src/launchd/liblaunch/liblaunch.dylib
compiler_rt src/external/compiler-rt/lib/builtins/libcompiler_rt.dylib
system_dyld src/dyld/libdyld.dylib
macho src/libmacho/libmacho.dylib
system_pthread src/external/libpthread/src/libsystem_pthread.dylib
platform src/external/libplatform/libsystem_platform.dylib
system_asl src/external/syslog/libsystem_asl.tproj/libsystem_asl.dylib
system_duct src/duct/src/libsystem_duct.dylib
system_blocks src/external/libclosure/libsystem_blocks.dylib
xpc src/external/libxpc/libxpc.dylib
corecrypto src/external/corecrypto/libcorecrypto.dylib
commonCrypto src/external/commoncrypto/libcommonCrypto.dylib
system_dnssd src/lib/system/dnssd/libsystem_dnssd.dylib
system_networkextension src/networkextension/libsystem_networkextension.dylib
unwind src/libunwind/libunwind.dylib
)
set_target_properties(system PROPERTIES OUTPUT_NAME "System.B")
set_property(TARGET system APPEND_STRING PROPERTY LINK_FLAGS
" -sub_library libsystem_malloc \
-sub_library libsystem_c \
-sub_library libsystem_kernel \
-sub_library libkeymgr \
-sub_library libsystem_m \
-sub_library libsystem_info \
-sub_library libsystem_notify \
-sub_library libquarantine \
-sub_library libsystem_blocks \
-sub_library libsystem_duct \
-sub_library libsystem_pthread \
-sub_library libsystem_platform \
-sub_library libsystem_trace \
-sub_library libdispatch \
-sub_library liblaunch \
-sub_library libremovefile \
-sub_library libcopyfile \
-sub_library libunwind \
-sub_library libdyld \
-sub_library libcompiler_rt \
-sub_library libmacho \
-sub_library libcommonCrypto \
-sub_library libsystem_sandbox \
-sub_library libsystem_coreservices \
-sub_library libsystem_coretls \
-sub_library libsystem_asl \
-sub_library libxpc \
-sub_library libcorecrypto \
-sub_library libsystem_dnssd \
-sub_library libsystem_networkextension \
-Wl,-compatibility_version,1.0.0 \
-Wl,-current_version,1238.0.0")
"-Wl,-compatibility_version,1.0.0 -Wl,-current_version,1238.0.0")
#make_fat(system)
make_fat(system)
install(TARGETS system DESTINATION libexec/darling/usr/lib)

View File

@ -1,9 +1,16 @@
project(libsandbox)
set(DYLIB_INSTALL_NAME "/usr/lib/system/libsystem_sandbox.dylib")
add_darling_library(sandbox SHARED sandbox.c)
target_link_libraries(sandbox PRIVATE system_c system_kernel system_dyld system_malloc)
set_target_properties(sandbox PROPERTIES OUTPUT_NAME "system_sandbox")
make_fat(sandbox)
add_circular(system_sandbox FAT
SOURCES
sandbox.c
install(TARGETS sandbox DESTINATION libexec/darling/usr/lib/system)
SIBLINGS
system_dyld
DEPENDENCIES
system_c
system_kernel
system_malloc
)
install(TARGETS system_sandbox DESTINATION libexec/darling/usr/lib/system)