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

Remove build script? #112

Open
madsmtm opened this issue Sep 30, 2024 · 1 comment
Open

Remove build script? #112

madsmtm opened this issue Sep 30, 2024 · 1 comment

Comments

@madsmtm
Copy link
Contributor

madsmtm commented Sep 30, 2024

I've been considering if we could get rid of the build script for determining the host architecture, using target_* cfgs instead of parsing the TARGET. Something like the following:

// Architecture
if cfg!(target_arch = "aarch64") {
    Architecture::Aarch64(if cfg!(target_endian = "big") { Aarch64Architecture::Aarch64be } else { Aarch64Architecture::Aarch64 })
} else if cfg!(target_arch = "x86_64") {
    Architecture::X86_64
} else if ... // etc.

// Vendor
if cfg!(target_vendor = "unknown") {
    Vendor::Amd
} else if cfg!(target_vendor = "amd") {
    Vendor::Amd
} else if ... // etc.

This would likely allow target-lexicon to be used in cc, which in turn would allow us to centralize target parsing even more, to the benefit of all in the ecosystem.


One complication though is that Rust's target_* cfgs aren't as descriptive, for example target_arch = "arm" is often used for several ARM architectures.

I think this may turn out to not really matter though, since there are fewer targets with host tool support? But then again, this would not allow us to distinguish between armv6-unknown-freebsd and armv7-unknown-freebsd, which, although tier 3, seemingly have host tool support.

There are several ways to solve this, including splitting the build script out into a separate crate that is only loaded when really needed, something like [target.armv7-unknown-freebsd.dependencies] target-lexion-with-build-script = "...".

@sunfishcode
Copy link
Member

There are ways to test for things like "v6" vs "v7", for example all(target_arch = "arm", target_feature = "v7"). I wonder if that goes far enough.

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

No branches or pull requests

2 participants