diff --git a/lang/llvm-17/Portfile b/lang/llvm-17/Portfile index d567453e31e4b..c88c52f80360b 100644 --- a/lang/llvm-17/Portfile +++ b/lang/llvm-17/Portfile @@ -29,7 +29,7 @@ version ${llvm_version}.0.6 name llvm-${llvm_version} revision 1 subport mlir-${llvm_version} { revision [ expr ${revision} + 0 ] } -subport clang-${llvm_version} { revision [ expr ${revision} + 2 ] } +subport clang-${llvm_version} { revision [ expr ${revision} + 3 ] } subport lldb-${llvm_version} { revision [ expr ${revision} + 1 ] } subport flang-${llvm_version} { revision [ expr ${revision} + 1 ] } @@ -224,6 +224,16 @@ if {${os.platform} eq "darwin" && ${os.major} <= 16} { patchfiles-append 0042-mbstate_t-not-defined.patch } +if {${os.platform} eq "darwin" && ${os.major} < 19} { + # https://trac.macports.org/ticket/68522 + # Undefined symbols for architecture x86_64: + # "__availability_version_check", referenced from: + # ___isPlatformVersionAtLeast in libclang_rt.osx.a(os_version_check.c.o) + # __initializeAvailabilityCheck in libclang_rt.osx.a(os_version_check.c.o) + # Upstream discussion at https://reviews.llvm.org/D150397 + patchfiles-append 0130-10.14-and-less-availability.patch +} + post-patch { reinplace "s|@@PREFIX@@|${prefix}|" \ ${patch.dir}/clang/lib/Driver/ToolChains/Clang.cpp \ diff --git a/lang/llvm-17/files/0130-10.14-and-less-availability.patch b/lang/llvm-17/files/0130-10.14-and-less-availability.patch new file mode 100644 index 0000000000000..eebb85b11ff42 --- /dev/null +++ b/lang/llvm-17/files/0130-10.14-and-less-availability.patch @@ -0,0 +1,32 @@ +This is a conditional revert of https://github.com/llvm/llvm-project/commit/b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0. +__attribute__((weak_import)) does not prevent Undefined symbol error. + +--- a/compiler-rt/lib/builtins/os_version_check.c.orig 2023-11-28 09:52:28.000000000 +0100 ++++ b/compiler-rt/lib/builtins/os_version_check.c 2024-08-28 18:19:16.000000000 +0200 +@@ -86,9 +86,11 @@ + CFStringEncoding); + typedef void (*CFReleaseFuncTy)(CFTypeRef); + ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + extern __attribute__((weak_import)) + bool _availability_version_check(uint32_t count, + dyld_build_version_t versions[]); ++#endif + + static void _initializeAvailabilityCheck(bool LoadPlist) { + if (AvailabilityVersionCheck && !LoadPlist) { +@@ -98,8 +100,14 @@ + } + + // Use the new API if it's is available. ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + if (_availability_version_check) + AvailabilityVersionCheck = &_availability_version_check; ++#else ++ // __attribute__((weak_import)) does not prevent Undefined symbol error on 10.14 ++ AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym( ++ RTLD_DEFAULT, "_availability_version_check"); ++#endif + + if (AvailabilityVersionCheck && !LoadPlist) { + // New API is supported and we're not being asked to load the plist, diff --git a/lang/llvm-18/Portfile b/lang/llvm-18/Portfile index 78883b9040828..2ad5001c3e98e 100644 --- a/lang/llvm-18/Portfile +++ b/lang/llvm-18/Portfile @@ -29,7 +29,7 @@ version ${llvm_version}.1.8 name llvm-${llvm_version} revision 0 subport mlir-${llvm_version} { revision [ expr ${revision} + 0 ] } -subport clang-${llvm_version} { revision [ expr ${revision} + 3 ] } +subport clang-${llvm_version} { revision [ expr ${revision} + 4 ] } subport lldb-${llvm_version} { revision [ expr ${revision} + 1 ] } subport flang-${llvm_version} { revision [ expr ${revision} + 1 ] } @@ -181,6 +181,16 @@ if {${os.platform} eq "darwin" && ${os.major} <= 16} { patchfiles-append 0041-no-Werror-unguarded-availability-new.patch } +if {${os.platform} eq "darwin" && ${os.major} < 19} { + # https://trac.macports.org/ticket/68522 + # Undefined symbols for architecture x86_64: + # "__availability_version_check", referenced from: + # ___isPlatformVersionAtLeast in libclang_rt.osx.a(os_version_check.c.o) + # __initializeAvailabilityCheck in libclang_rt.osx.a(os_version_check.c.o) + # Upstream discussion at https://reviews.llvm.org/D150397 + patchfiles-append 0130-10.14-and-less-availability.patch +} + post-patch { reinplace "s|@@PREFIX@@|${prefix}|" \ ${patch.dir}/clang/lib/Driver/ToolChains/Clang.cpp \ diff --git a/lang/llvm-18/files/0130-10.14-and-less-availability.patch b/lang/llvm-18/files/0130-10.14-and-less-availability.patch new file mode 100644 index 0000000000000..6e08aaeffff5f --- /dev/null +++ b/lang/llvm-18/files/0130-10.14-and-less-availability.patch @@ -0,0 +1,40 @@ +This is a conditional revert of https://github.com/llvm/llvm-project/commit/b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0. +__attribute__((weak_import)) does not prevent Undefined symbol error. + +--- a/compiler-rt/lib/builtins/os_version_check.c.orig 2023-11-28 09:52:28.000000000 +0100 ++++ b/compiler-rt/lib/builtins/os_version_check.c 2024-08-29 15:29:18.000000000 +0200 +@@ -13,6 +13,7 @@ + + #ifdef __APPLE__ + ++#include + #include + #include + #include +@@ -86,9 +87,11 @@ + CFStringEncoding); + typedef void (*CFReleaseFuncTy)(CFTypeRef); + ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + extern __attribute__((weak_import)) + bool _availability_version_check(uint32_t count, + dyld_build_version_t versions[]); ++#endif + + static void _initializeAvailabilityCheck(bool LoadPlist) { + if (AvailabilityVersionCheck && !LoadPlist) { +@@ -98,8 +101,14 @@ + } + + // Use the new API if it's is available. ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + if (_availability_version_check) + AvailabilityVersionCheck = &_availability_version_check; ++#else ++ // __attribute__((weak_import)) does not prevent Undefined symbol error on 10.14 ++ AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym( ++ RTLD_DEFAULT, "_availability_version_check"); ++#endif + + if (AvailabilityVersionCheck && !LoadPlist) { + // New API is supported and we're not being asked to load the plist, diff --git a/lang/llvm-19/Portfile b/lang/llvm-19/Portfile index a7f811a11ade4..a93140d2fcae6 100644 --- a/lang/llvm-19/Portfile +++ b/lang/llvm-19/Portfile @@ -29,7 +29,7 @@ version ${llvm_version}.1.6 name llvm-${llvm_version} revision 0 subport mlir-${llvm_version} { revision [ expr ${revision} + 0 ] } -subport clang-${llvm_version} { revision [ expr ${revision} + 0 ] } +subport clang-${llvm_version} { revision [ expr ${revision} + 1 ] } subport lldb-${llvm_version} { revision [ expr ${revision} + 0 ] } subport flang-${llvm_version} { revision [ expr ${revision} + 0 ] } @@ -176,6 +176,16 @@ if {${os.platform} eq "darwin" && ${os.major} <= 16} { patchfiles-append 0041-no-Werror-unguarded-availability-new.patch } +if {${os.platform} eq "darwin" && ${os.major} < 19} { + # https://trac.macports.org/ticket/68522 + # Undefined symbols for architecture x86_64: + # "__availability_version_check", referenced from: + # ___isPlatformVersionAtLeast in libclang_rt.osx.a(os_version_check.c.o) + # __initializeAvailabilityCheck in libclang_rt.osx.a(os_version_check.c.o) + # Upstream discussion at https://reviews.llvm.org/D150397 + patchfiles-append 0130-10.14-and-less-availability.patch +} + post-patch { reinplace "s|@@PREFIX@@|${prefix}|" \ ${patch.dir}/clang/lib/Driver/ToolChains/Clang.cpp \ diff --git a/lang/llvm-19/files/0130-10.14-and-less-availability.patch b/lang/llvm-19/files/0130-10.14-and-less-availability.patch new file mode 100644 index 0000000000000..6e08aaeffff5f --- /dev/null +++ b/lang/llvm-19/files/0130-10.14-and-less-availability.patch @@ -0,0 +1,40 @@ +This is a conditional revert of https://github.com/llvm/llvm-project/commit/b653a2823fe4b4c9c6d85cfe119f31d8e70c2fa0. +__attribute__((weak_import)) does not prevent Undefined symbol error. + +--- a/compiler-rt/lib/builtins/os_version_check.c.orig 2023-11-28 09:52:28.000000000 +0100 ++++ b/compiler-rt/lib/builtins/os_version_check.c 2024-08-29 15:29:18.000000000 +0200 +@@ -13,6 +13,7 @@ + + #ifdef __APPLE__ + ++#include + #include + #include + #include +@@ -86,9 +87,11 @@ + CFStringEncoding); + typedef void (*CFReleaseFuncTy)(CFTypeRef); + ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + extern __attribute__((weak_import)) + bool _availability_version_check(uint32_t count, + dyld_build_version_t versions[]); ++#endif + + static void _initializeAvailabilityCheck(bool LoadPlist) { + if (AvailabilityVersionCheck && !LoadPlist) { +@@ -98,8 +101,14 @@ + } + + // Use the new API if it's is available. ++#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 + if (_availability_version_check) + AvailabilityVersionCheck = &_availability_version_check; ++#else ++ // __attribute__((weak_import)) does not prevent Undefined symbol error on 10.14 ++ AvailabilityVersionCheck = (AvailabilityVersionCheckFuncTy)dlsym( ++ RTLD_DEFAULT, "_availability_version_check"); ++#endif + + if (AvailabilityVersionCheck && !LoadPlist) { + // New API is supported and we're not being asked to load the plist,