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-14: Fix build under Xcode 15, re-enabling sanitizers on macOS 14 #20625

Merged
merged 1 commit into from
Sep 28, 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
27 changes: 17 additions & 10 deletions lang/llvm-14/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-14/Portfile

View workflow job for this annotation

GitHub Actions / macos-11

port lint llvm-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-11

port lint clang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-11

port lint mlir-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-11

port lint flang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-11

port lint lldb-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-12

port lint llvm-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-12

port lint clang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-12

port lint mlir-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-12

port lint flang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-12

port lint lldb-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-13

port lint llvm-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-13

port lint clang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-13

port lint mlir-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-13

port lint flang-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

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

View workflow job for this annotation

GitHub Actions / macos-13

port lint lldb-14: Warning: Line 536 contains tab but modeline says tabs should be expanded Warning: Line 537 contains tab but modeline says tabs should be expanded Warning: Line 538 contains tab but modeline says tabs should be expanded Warning: Line 539 contains tab but modeline says tabs should be expanded Warning: Line 540 contains tab but modeline says tabs should be expanded

PortSystem 1.0
PortGroup select 1.0
Expand Down Expand Up @@ -27,7 +27,7 @@
name llvm-${llvm_version}
revision 0
subport mlir-${llvm_version} { revision 0 }
subport clang-${llvm_version} { revision 1 }
subport clang-${llvm_version} { revision 2 }
subport lldb-${llvm_version} { revision 1 }
subport flang-${llvm_version} { revision 0 }

Expand Down Expand Up @@ -136,7 +136,8 @@
MachOWriter.cpp-types.patch \
SyntheticSections.cpp-types.patch \
patch-lldb-stdc-macros-134877.diff \
patch-lldb-fix-swig-lvalue-2128646.diff
patch-lldb-fix-swig-lvalue-2128646.diff \
patch-xcode-15.diff

if {${os.platform} eq "darwin" && ${os.major} < 14} {
patchfiles-append \
Expand Down Expand Up @@ -331,14 +332,6 @@
-DCOMPILER_RT_BUILD_MEMPROF=OFF
}

if {${os.platform} eq "darwin" && ${os.major} > 22} {
# sanitizers also fail to build on macOS14
# https://trac.macports.org/ticket/68257
configure.args-append -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_MEMPROF=OFF
}

if {${os.platform} eq "darwin" && ${os.major} <= 11} {
# xpc.h available 10.7 but doesn't support nullable features
configure.args-append -DCLANGD_BUILD_XPC=OFF
Expand Down Expand Up @@ -538,6 +531,20 @@
if { ${cxx_stdlib} eq "libstdc++" } {
default_variants-append +libstdcxx
}

post-configure {
# -Wl,-syslibroot referencing the macOS SDK must not appear when linking
# runtime libraries for non-macOS platforms, which are cross-built and
# used for cross-platform support. The clang build will provide the
# proper -isysroot for the platform in these cases. Remove the macOS
# SDK.
foreach rtl_dir {asan lsan stats tsan/rtl ubsan ubsan_minimal} {
set rtl [lindex [split ${rtl_dir} /] 0]
foreach rtl_os {ios iossim} {
reinplace "s|-Wl,-syslibroot,${configure.sdkroot}||" "${workpath}/build/projects/compiler-rt/lib/${rtl_dir}/CMakeFiles/clang_rt.${rtl}_${rtl_os}_dynamic.dir/link.txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that we should also do for clang-15 and newer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ports for clang-15 and newer don’t build runtime libraries for ios and iossim at the moment, because

# Disable iOS support
# To Be reviewed with later versions
# https://reviews.llvm.org/D133273
configure.args-append -DCOMPILER_RT_ENABLE_IOS=OFF

I’m not sure exactly why this was disabled—if it was for this reason, then yes, sure. But I don’t know whether there’s another reason standing in the way. That’s why I only did it for clang-14.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, good point. It would be good to review that at some point but its not required for this PR. Thanks for your contribution...

}
}
}
}

livecheck.type regex
Expand Down
47 changes: 47 additions & 0 deletions lang/llvm-14/files/patch-xcode-15.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From 786c10cd82a78c210379700b72cf18a018e1e1f7 Mon Sep 17 00:00:00 2001
From: Mark Mentovai <mark@mentovai.com>
Date: Thu, 28 Sep 2023 11:18:41 -0400
Subject: [PATCH] [sanitizer] Use consistent checks for XDR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a backport of 28800c2e18972935cd4f942aa428c5e6cc4c1670
(https://reviews.llvm.org/D130060), which is in llvm-15, to llvm-14,
however it’s been adapted to be
pre-8246b2e156568c31e71e16cbaf4c14d316e7c06e
(https://reviews.llvm.org/D126263), which renamed SANITIZER_MAC (the
macro in llvm-14) to SANITIZER_APPLE (the macro in llvm-15 and later).

The original change’s description:

> sanitizer_platform_limits_posix.h defines `__sanitizer_XDR ` if
> `SANITIZER_LINUX && !SANITIZER_ANDROID`, but
> sanitizer_platform_limits_posix.cpp tries to check it if
> `HAVE_RPC_XDR_H`. This coincidentally works because macOS has a broken
> <rpc/xdr.h> which causes `HAVE_RPC_XDR_H` to be 0, but if <rpc/xdr.h>
> is fixed then clang fails to compile on macOS. Restore the platform
> checks so that <rpc/xdr.h> can be fixed on macOS.

This has become important with Xcode 15, which contains the macOS 14
SDK, which does have a fixed <rpc/xdr.h>.
---
.../lib/sanitizer_common/sanitizer_platform_limits_posix.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index 32b8f47ed633..6cefef3f3327 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -1250,7 +1250,7 @@ CHECK_SIZE_AND_OFFSET(group, gr_passwd);
CHECK_SIZE_AND_OFFSET(group, gr_gid);
CHECK_SIZE_AND_OFFSET(group, gr_mem);

-#if HAVE_RPC_XDR_H
+#if HAVE_RPC_XDR_H && !SANITIZER_MAC
CHECK_TYPE_SIZE(XDR);
CHECK_SIZE_AND_OFFSET(XDR, x_op);
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
--
2.42.0

Loading