Odin
Odin copied to clipboard
Select OS target as a odin compiler flag
I just started exploring Odin and the learn_metal examples, but there was a problem related to Metal version:
error: 'id' attribute requires Metal language standard macos-metal2.0 or higher;
I tried searching for any flag related to this matter but Odin had none. So I tried compiling Odin with -mmacosx-version-min=12.0
since Odin was compiling the learn_metal example targeting min MacOS version 10.12 (which used metal1). Even with the flag set on Odin's build_odin.sh
file, it could not run properly. I found out that in src/main.cpp there was this condition:
if (build_context.metrics.os == TargetOs_darwin) {
if (build_context.metrics.arch == TargetArch_arm64) {
link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=12.0.0 ");
} else {
link_settings = gb_string_appendc(link_settings, " -mmacosx-version-min=10.12.0 ");
}
link_settings = gb_string_appendc(link_settings, " -e _main ");
}
The problem with it is that even Macbooks like mine (Macbook Pro 2020 - Macos 12.3.1) would target MacOs min version of 10.12, just because it's not Arm based. After changing the condition to target 12.0, every other example ran smoothly.
My suggestion: Add flags to control which OS version the compiler should target.
Example:
odin run . --target=macos12.0
The idea is very raw, but the problem is real. So I guess that after putting some think on it, there may be a good syntax for this flag. This idea is also important because it can influence not only MacOS, but even other OS's.
So, there is a command for specifying the target, but not the VERSION. This macos12.0 problem is due to de darwin-target version and not the target itself.
I still wish there'd be a flag to determine the version instead of changing the src/main.cpp file everytime :/
It's certainly an idea to add a -target-version
flag or something of that nature.
Does -extra-linker-flags:<string>
do anything for you?
@Kelimion I'm having this problem as well, and -extra-linker-flags
does not seem to work to configure this (at least -extra-linker-flags:"-mmacosx-version-min=12.0.0"
doesn't work). This is not just important for Metal but also for more basic features. For example, opening a window doesn't cause the window to obey the system dark mode settings unless there's a newer MacOS SDK version specified.
I think -target-version
or something similar would be a nice addition to avoid having to recompile the compiler.
I've added the following, which will be merged shortly:
-minimum-os-version:<string>
Sets the minimum OS version targeted by the application
e.g. -minimum-os-version:12.0.0
(Only used when target is Darwin)