diff --git a/.release-notes/ldclassic.md b/.release-notes/ldclassic.md new file mode 100644 index 0000000000..273bc82c4e --- /dev/null +++ b/.release-notes/ldclassic.md @@ -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. diff --git a/src/libponyc/CMakeLists.txt b/src/libponyc/CMakeLists.txt index 847ab9bc8b..5a0336eac1 100644 --- a/src/libponyc/CMakeLists.txt +++ b/src/libponyc/CMakeLists.txt @@ -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) @@ -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} "$" ${LLVM_OBJS} "${PROJECT_SOURCE_DIR}/../../build/libs/lib/blake2.lib" DEPENDS libponyc) add_custom_command(TARGET libponyc-standalone POST_BUILD diff --git a/src/libponyc/codegen/codegen.c b/src/libponyc/codegen/codegen.c index c79df1200e..9a903670b9 100644 --- a/src/libponyc/codegen/codegen.c +++ b/src/libponyc/codegen/codegen.c @@ -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 diff --git a/src/libponyc/codegen/genexe.c b/src/libponyc/codegen/genexe.c index 8b3af7805b..4d6299e326 100644 --- a/src/libponyc/codegen/genexe.c +++ b/src/libponyc/codegen/genexe.c @@ -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 ); diff --git a/src/libponyrt/CMakeLists.txt b/src/libponyrt/CMakeLists.txt index d9b6fb9b81..f2cc37e7cd 100644 --- a/src/libponyrt/CMakeLists.txt +++ b/src/libponyrt/CMakeLists.txt @@ -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}