-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
Is subtarget
the best way to do it?
#4457
Comments
Yes this is the best way to do it. Subtargets like They share a lot of the same stuff any way and the main difference between them is mostly certain SDKs and linking changes. Odin is very consistent in that it's For Android I'd just have that be the a |
I omited some details, sorry for that. I don't want to mark them as a diffrent OS, on a contrary I'm quite opposed to it. The change will not affect user code, only the internal handling in the compiler and the flags So the gb_global TargetMetrics target_darwin_amd64 = {
TargetOs_darwin,
TargetArch_amd64,
8, 8, AMD64_MAX_ALIGNMENT, 32,
str_lit("x86_64-apple-macosx"),
};
gb_global TargetMetrics target_darwin_arm64 = {
TargetOs_darwin,
TargetArch_arm64,
8, 8, 16, 32,
str_lit("arm64-apple-macosx"),
};
gb_global TargetMetrics target_ios_amd64 = {
TargetOs_darwin,
TargetArch_amd64,
8, 8, AMD64_MAX_ALIGNMENT, 32,
str_lit("x86_64-apple-ios"),
Subtarget_iOS,
};
gb_global TargetMetrics target_ios_arm64 = {
TargetOs_darwin,
TargetArch_arm64,
8, 8, 16, 32,
str_lit("arm64-apple-ios"),
Subtarget_iOS,
};
|
Doesn't ios implies Darwin? It does. Doesn't android implies Linux? It does. Does it makes sense to write If you don't like |
You are correct that this doesn't make sense: But it's literally a subtarget and the compiler will literally check for valid combinations. |
So you're saying that the cli backward compatibility is more important here. That's reasonable. Now though what's the intention for making it a separate flag? Why not have a separate os and arch then? I don't understand. |
cli flags don't bother me a lot, but the fact that currently subtargets don't get default values (unlike metrics), also that you cannot specify a subtarget without a target and the fact that subtarget does an ugly patch for the metrics. Those do bother me. You must elaborate on those points. It's silly to be required to always run odin with |
The way it's implemented is kind of messy. Instead of patching
TargetMetrics
Odin/src/build_settings.cpp
Lines 1613 to 1624 in 1419d0d
Isn't it better to just list the variations explicitly in
build_settings.cpp
?It's not too bad for iOS, but for android, the values differ not only for target triple, but also int_size and ptr_size, as well as there are things like
i686-linux-android
that don't have base target listed inbuild_settings.cpp
.And with explicit listing we could add the
subtarget
field toTargetMetrics
and make choosing subtarget more turse and more natural.-target:darwin_amd64 -subtarget:ios
->
-target:ios_amd64
And with explicit listing it's much more straight forward to allow the default
TargetMetrics
to be correct:src/gb/gb.h
:init_build_context
And that's it!
All the metrics are alreay available in the build_context, so just change the
selected_subtarget
tobuild_context.metrics.subtarget
P.S. I understand where the name
subtarget
comes from, but I feel like it could be better called something along the lines ofdistro
, but hey, the bike shed can be red!The text was updated successfully, but these errors were encountered: