-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
shims/super/cc: tweak optimisation flag handling for runtime CPU detection builds #19551
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the handling of optimization flags to support runtime CPU detection builds on arm64 macOS by adjusting how flags such as -mcpu and -mtune are processed.
- Removed -mtune and -mcpu flag matching from the first case and placed them in a separate condition for CPU detection.
- Replaced a blanket concatenation of optflags with an iteration that checks for conflicts with existing flags.
Comments suppressed due to low confidence (1)
Library/Homebrew/shims/super/cc:204
- Confirm that moving the -mtune and -mcpu flags here maintains the intended flag precedence and does not affect builds on platforms other than arm64.
when /^-march=.+/, /^-mtune=.+/, /^-mcpu=.+/
Why? |
Not really sure, but dropping the |
|
Does it? Looks like it's actually our stripping of It's compiling as aarch32 because this is wrong: https://github.com/nss-dev/nss/blob/b6a1be96fba1c400d77698bde71ccaec6796e86d/coreconf/Darwin.mk#L18 + https://github.com/nss-dev/nss/blob/b6a1be96fba1c400d77698bde71ccaec6796e86d/coreconf/Darwin.mk#L34. You can override |
Won't that make the build assume a PowerPC build? |
…ction builds Let's reinstate adding our own optimisation flags if the compiler was not invoked with a conflicting optimisation flag.
e285a2a to
351f7f8
Compare
|
Dropped the |
Ah right yeah, probably needs something like: diff --git a/coreconf/Darwin.mk b/coreconf/Darwin.mk
index 0569e1819..d1893adb4 100644
--- a/coreconf/Darwin.mk
+++ b/coreconf/Darwin.mk
@@ -31,13 +31,19 @@ override CPU_ARCH = x86
endif
else
ifeq (arm,$(CPU_ARCH))
-# Nothing set for arm currently.
+ifdef USE_64
+CC += -arch arm64
+CCC += -arch arm64
+override CPU_ARCH = aarch64
+endif
else
+ifeq (ppc,$(CPU_ARCH))
OS_REL_CFLAGS = -Dppc
CC += -arch ppc
CCC += -arch ppc
endif
endif
+endif
ifneq (,$(MACOS_SDK_DIR))
GCC_VERSION_FULL := $(shell $(CC) -dumpversion)or I guess |
|
Hi @carlocab, apologies if this is the wrong place to post. I'm debugging a formula build failure in this PR: I think I've tracked the failure down to the Is it possible the shim would filter out the Again, sorry if I'm barking up the wrong tree. I'm not very experienced in Homebrew's workings, nor Ruby. |
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?We need to allow-mcpuand-mtuneflags to avoid breaking builds onarm64 macOS. See, for example, Homebrew/homebrew-core#212051.Also, let's reinstate adding our own optimisation flags if the compiler
was not invoked with a conflicting optimisation flag.