Skip to content

fix Apple compiler detection regression#992

Closed
brodo wants to merge 1 commit into
Vexu:masterfrom
brodo:target-cond-regression
Closed

fix Apple compiler detection regression#992
brodo wants to merge 1 commit into
Vexu:masterfrom
brodo:target-cond-regression

Conversation

@brodo
Copy link
Copy Markdown
Contributor

@brodo brodo commented Apr 12, 2026

This PR sets TARGET_CPU_ and TARGET_OS_ when targeting Apple OSes.

TargetConditionals.h has been updated recently and which leads to arocc not being able to compile Libraries that use it. As an example, see the zig16-dev branch of dvui.

In TargetConditionals.h, the suggested fix is described on line 385:

The short term work around is to set the TARGET_CPU_ and TARGET_OS_
on the command line to the compiler (e.g. -DTARGET_CPU_MIPS=1 -DTARGET_OS_UNIX=1)

This PR does just that.

@Vexu
Copy link
Copy Markdown
Owner

Vexu commented Apr 28, 2026

Can you point to me to the version of TargetConditionals.h that is causing these issues? The one included with IOS 26 SDK seems like it should still work as is.

To properly match the Clang extension all the TARGET_OS_ macros should be defined for all targets and it should be possible to enable them even on non Apple OSes with -fdefine-target-os-macros.

And I don't think we need to define any TARGET_CPU_ macros since Clang doesn't and we emulate Clang on MacOS.

@brodo
Copy link
Copy Markdown
Contributor Author

brodo commented Apr 28, 2026

Can you point to me to the version of TargetConditionals.h that is causing these issues? The one included with IOS 26 SDK seems like it should still work as is.

On macOS 16.24.1 with the newest Xcode it is at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/TargetConditionals.h

You can also view it here.

To properly match the Clang extension all the TARGET_OS_ macros should be defined for all targets and it should be possible to enable them even on non Apple OSes with -fdefine-target-os-macros.

I can implement this tomorrow.

And I don't think we need to define any TARGET_CPU_ macros since Clang doesn't and we emulate Clang on MacOS.

Clang implements two special functions: __is_target_arch and __is_target_os, so it does not need the defines. Implementing these functions in Aro would also be an option.

@ehaas
Copy link
Copy Markdown
Collaborator

ehaas commented Apr 28, 2026

Clang implements two special functions: __is_target_arch and __is_target_os, so it does not need the defines. Implementing these functions in Aro would also be an option.

Aro has those functions; they aren't heavily tested or used though so it's possible they don't work exactly how clang's do.

@brodo
Copy link
Copy Markdown
Contributor Author

brodo commented Apr 29, 2026

Ok, so IMHO the best solution would be to fix any differences between Aro's and clang's version. My plan is to first port Clangs tests for __is_target_arch and __is_target_os to Aro. Here is a list:

@brodo
Copy link
Copy Markdown
Contributor Author

brodo commented May 1, 2026

I'm closing this because I've 90% of a PR done which makes the clang tests run under Aro. New PR comes tomorrow!

@brodo brodo closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants