Merge pull request #15511 from mikdusan/netbsd-pkgsrc

netbsd: pkgsrc
This commit is contained in:
Andrew Kelley 2023-06-17 14:22:43 -07:00 committed by GitHub
commit e23d48e61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -120,6 +120,8 @@ if(ZIG_AR_WORKAROUND)
string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
endif()
set(ZIG_PIE off CACHE BOOL "produce a position independent zig executable")
find_package(llvm 16)
find_package(clang 16)
find_package(lld 16)
@ -671,7 +673,12 @@ if(ZIG_STATIC)
endif()
add_library(zigcpp STATIC ${ZIG_CPP_SOURCES})
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${EXE_CXX_FLAGS})
if(ZIG_PIE)
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS} -fPIC")
else()
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS}")
endif()
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${ZIGCPP_CXX_FLAGS})
target_link_libraries(zigcpp LINK_PUBLIC
${CLANG_LIBRARIES}
@ -823,10 +830,10 @@ else()
set(ZIG_STATIC_ARG "")
endif()
if(CMAKE_POSITION_INDEPENDENT_CODE)
set(ZIG_PIE_ARG="-Dpie")
if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
set(ZIG_PIE_ARG "-Dpie")
else()
set(ZIG_PIE_ARG="")
set(ZIG_PIE_ARG "")
endif()
set(ZIG_BUILD_ARGS

View File

@ -1667,10 +1667,10 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
try argv.append("-pie");
}
if (self.base.options.link_mode == .Dynamic and target.os.tag == .netbsd) {
if (is_dyn_lib and target.os.tag == .netbsd) {
// Add options to produce shared objects with only 2 PT_LOAD segments.
// NetBSD expects 2 PT_LOAD segments in a shared object, otherwise
// ld.elf_so fails to load, emitting a general "not found" error.
// ld.elf_so fails loading dynamic libraries with "not found" error.
// See https://github.com/ziglang/zig/issues/9109 .
try argv.append("--no-rosegment");
try argv.append("-znorelro");