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

clang-{17,18,19}: unbreak @available on MacOS 10.14 #25514

Merged
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
12 changes: 11 additions & 1 deletion lang/llvm-17/Portfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

Check warning on line 1 in lang/llvm-17/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port test clang-17: Warning: clang-17 is configured to build for the architecture(s) 'x86_64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

Check warning on line 1 in lang/llvm-17/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port test clang-17: Warning: clang-17 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

Check warning on line 1 in lang/llvm-17/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port test clang-17: Warning: clang-17 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-17/lib/clang/17/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

PortSystem 1.0
PortGroup select 1.0
Expand Down Expand Up @@ -29,7 +29,7 @@
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 ] }

Expand Down Expand Up @@ -224,6 +224,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 \
Expand Down
32 changes: 32 additions & 0 deletions lang/llvm-17/files/0130-10.14-and-less-availability.patch
Original file line number Diff line number Diff line change
@@ -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,
12 changes: 11 additions & 1 deletion lang/llvm-18/Portfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

Check warning on line 1 in lang/llvm-18/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port test clang-18: Warning: clang-18 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

Check warning on line 1 in lang/llvm-18/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port test clang-18: Warning: clang-18 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-18/lib/clang/18/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

PortSystem 1.0
PortGroup select 1.0
Expand Down Expand Up @@ -29,7 +29,7 @@
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 ] }

Expand Down Expand Up @@ -181,6 +181,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 \
Expand Down
40 changes: 40 additions & 0 deletions lang/llvm-18/files/0130-10.14-and-less-availability.patch
Original file line number Diff line number Diff line change
@@ -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 <AvailabilityMacros.h>
#include <TargetConditionals.h>
#include <dispatch/dispatch.h>
#include <dlfcn.h>
@@ -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,
12 changes: 11 additions & 1 deletion lang/llvm-19/Portfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

Check warning on line 1 in lang/llvm-19/Portfile

View workflow job for this annotation

GitHub Actions / macos-13

port test clang-19: Warning: clang-19 is configured to build for the architecture(s) 'x86_64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

Check warning on line 1 in lang/llvm-19/Portfile

View workflow job for this annotation

GitHub Actions / macos-14

port test clang-19: Warning: clang-19 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

Check warning on line 1 in lang/llvm-19/Portfile

View workflow job for this annotation

GitHub Actions / macos-15

port test clang-19: Warning: clang-19 is configured to build for the architecture(s) 'arm64', but installed Mach-O files built for the following archs: Warning: arm64,x86_64,x86_64: Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.stats_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib Warning: /opt/local/libexec/llvm-19/lib/clang/19/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib Warning:

PortSystem 1.0
PortGroup select 1.0
Expand Down Expand Up @@ -29,7 +29,7 @@
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 ] }

Expand Down Expand Up @@ -176,6 +176,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 \
Expand Down
40 changes: 40 additions & 0 deletions lang/llvm-19/files/0130-10.14-and-less-availability.patch
Original file line number Diff line number Diff line change
@@ -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 <AvailabilityMacros.h>
#include <TargetConditionals.h>
#include <dispatch/dispatch.h>
#include <dlfcn.h>
@@ -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,
Loading