Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiling Pony programs on X86 MacOS when XCode 15 is the linker #4466

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release-notes/ldclassic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Fix compiling Pony programs on X86 MacOS when XCode 15 is the linker

With the introduction of XCode 15, you could no longer link Pony programs on X86 MacOS. We've fixed the issue. Apple Silicon was uneffected.
6 changes: 5 additions & 1 deletion src/libponyc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ target_include_directories(libponyc
PRIVATE ../../lib/blake2
)

if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0.0)
endif()

if (MSVC)
file(GLOB_RECURSE CFILES "${PROJECT_SOURCE_DIR}/*.c")
set_source_files_properties(${CFILES} PROPERTIES LANGUAGE CXX)
Expand All @@ -126,7 +130,7 @@ if (MSVC)
set(libponyc_standalone_file "${CMAKE_STATIC_LIBRARY_PREFIX}ponyc-standalone${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(libponyc_standalone_path "${CMAKE_BINARY_DIR}/${libponyc_standalone_file}")
add_custom_target(libponyc-standalone ALL
# CMAKE_AR finds the appropriate version of lib.exe acdording to desired target and host architecture
# CMAKE_AR finds the appropriate version of lib.exe acdording to desired target and host architecture
COMMAND ${CMAKE_AR} /NOLOGO /VERBOSE /MACHINE:x64 /OUT:${libponyc_standalone_path} "$<TARGET_FILE:libponyc>" ${LLVM_OBJS} "${PROJECT_SOURCE_DIR}/../../build/libs/lib/blake2.lib"
DEPENDS libponyc)
add_custom_command(TARGET libponyc-standalone POST_BUILD
Expand Down
7 changes: 4 additions & 3 deletions src/libponyc/codegen/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,10 @@ bool codegen_pass_init(pass_opt_t* opt)
{
triple = LLVMCreateMessage(opt->triple);
} else {
#if defined(PLATFORM_IS_MACOSX) && !defined(PLATFORM_IS_ARM)
// This is to prevent XCode 7+ from claiming OSX 14.5 is required.
triple = LLVMCreateMessage("x86_64-apple-macosx");
#if defined(PLATFORM_IS_MACOSX) && defined(PLATFORM_IS_ARM)
triple = LLVMCreateMessage("arm64-apple-macosx13.0.0");
#elif defined(PLATFORM_IS_MACOSX) && !defined(PLATFORM_IS_ARM)
triple = LLVMCreateMessage("x86_64-apple-macosx13.0.0");
#else
triple = LLVMGetDefaultTargetTriple();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/libponyc/codegen/genexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static bool link_exe(compile_t* c, ast_t* program,
snprintf(ld_cmd, ld_len,
"%s -execute -arch %.*s "
"-o %s %s %s %s "
"-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem %s",
"-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem %s -platform_version macos '13.0.0' '0.0.0'",
linker, (int)arch_len, c->opt->triple, file_exe, file_o,
lib_args, ponyrt, sanitizer_arg
);
Expand Down
4 changes: 4 additions & 0 deletions src/libponyrt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ find_file(_llc_command
PATHS "${CMAKE_BINARY_DIR}/../../libs/bin" "${CMAKE_BINARY_DIR}/../libs/bin"
)

if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0.0)
endif()

add_library(libponyrt STATIC
${_c_src}
${_ll_except_obj}
Expand Down
Loading