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

Build gcc with current Homebrew patches and remove lib*san on Ventura #1033

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dhomeier
Copy link
Contributor

@dhomeier dhomeier commented Jun 1, 2023

Building the AddressSanitizer and ThreadSanitizer tools libasan and libubsan is broken on macOS >= 13 and has thus been disabled in the latest gcc branches:
iains/gcc-darwin-arm64@e722a1f4
Those files are therefore missing from the shlibs SplitOff, accommodated in a separate .info for Distribution: 13.0 (for lack of an easier way to handle this for now). Also pulling in the current patches from the gcc arm64 team copied from Homebrew.

Tested on 12.7 and 13.4 arm64 and x86_64/Rosetta, and on 10.14.6 x86_64; should especially be tested on 13.x and 14.x with Xcode 15; if this is an acceptable solution, the gcc updates for 12.3.0 and 13.1.0 can be handled in the same way.

@dhomeier dhomeier added the arm64 Build issues and fixes for Apple Silicon label Jun 1, 2023
dhomeier referenced this pull request Jun 1, 2023
@dhomeier dhomeier requested a review from nieder June 1, 2023 22:40
@nieder
Copy link
Member

nieder commented Jun 3, 2023

Thanks for working this.
Built here on 10.14.6. I don't have any arm64 to test it on, unfortunately.

%r needs to be bumped because there are changes in the build (like all the PIE things) that affect the end result.
Does anything external actually use libasan and libubsan ?

@dhomeier
Copy link
Contributor Author

dhomeier commented Jun 4, 2023

%r needs to be bumped because there are changes in the build (like all the PIE things) that affect the end result.

Of course, and 11.4.0-1 is already in...

Does anything external actually use libasan and libubsan ?

Not aware of any packages, and admittedly I don't know about their exact usage. The documentation has not seen much activity, but the code is still getting some updates merged in from LLVM. So as long as some users might have a use for them, I thought as long as they build we may as well distribute them.
Of course it would simplify packaging a bit to strip them on all platforms or disable the build right away (could modify the patch accordingly if there is no config switch otherwise).

@dhomeier
Copy link
Contributor Author

dhomeier commented Oct 4, 2023

Rebased this, leaving the libsanitizer build enabled for arm64 – I have tested some of the example functions from
https://github.com/google/sanitizers/wiki/AddressSanitizer and https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
on 12.7/arm64 and they seem to be at least partly functional, although the output e.g. from use-after-free.c looks quite different on arm64 than on x86_64.

@cooljeanius
Copy link

I tested this PR on Big Sur with Xcode 13, but got these results:

$ fink -m install gcc11
Scanning package description files..........
Information about 15255 packages read in 5 seconds.
Running in Maintainer Mode
Validating package file /opt/sw/fink/dists/stable/main/finkinfo/languages/gcc11.info...
Warning: Field "infodocs" is deprecated. (gcc11.info)
Package looks good!
The package 'gcc11' will be built and installed.
Reading build dependency for gcc11-11.4.0-2...
Can't resolve dependency "xcode (>= 14.2.0)" for package "gcc11-11.4.0-2" (no matching packages/versions found)
Exiting with failure.

@dhomeier
Copy link
Contributor Author

Can't resolve dependency "xcode (>= 14.2.0)" for package "gcc11-11.4.0-2" (no matching packages/versions found)

Right; forgot that Xcode 14 again will not be available at older macOS versions – so that would need another separate build for 12.0; or since the requirement is just for the libsanitizer build on arm64, restrict it to that.
There is no working arm64 distribution for Big Sur or earlier, or is there?

@cooljeanius
Copy link

Can't resolve dependency "xcode (>= 14.2.0)" for package "gcc11-11.4.0-2" (no matching packages/versions found)

Right; forgot that Xcode 14 again will not be available at older macOS versions – so that would need another separate build for 12.0; or since the requirement is just for the libsanitizer build on arm64, restrict it to that.

OK thanks, I can confirm that 6c81990 fixed this.

There is no working arm64 distribution for Big Sur or earlier, or is there?

My machine is x86_64, so I wouldn't know...

Copy link

@cooljeanius cooljeanius left a comment

Choose a reason for hiding this comment

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

I managed to build this PR successfully on x86_64 Big Sur with Xcode 13; it's probably good to go.

@sth0
Copy link
Contributor

sth0 commented Oct 26, 2023

This PR allows build of gcc 11 on MacOS 13.6 (Ventura) X86_64 with Xcode 15.0 and associated CLT.

@cooljeanius
Copy link

@nieder can you approve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm64 Build issues and fixes for Apple Silicon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants