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

Update roc build --target to add more triples #5577

Merged
merged 24 commits into from
Jul 11, 2023
Merged

Update roc build --target to add more triples #5577

merged 24 commits into from
Jul 11, 2023

Conversation

rtfeldman
Copy link
Sponsor Contributor

@rtfeldman rtfeldman commented Jun 20, 2023

Now the CLI supports all of these --target flags:

  • linux-x64
  • linux-x32
  • linux-arm64
  • macos-x64
  • macos-arm64
  • windows-x64
  • wasm32

The naming scheme is not exactly what clang and friends use, but it is designed to:

  • Be easy to learn for someone who isn't necessarily familiar with target triple syntax. (e.g. everyone says "x64" so use that over e.g. amd64 like Docker uses. Nobody talks much about 32-bit x86 anymore, so just call it x32 for symmetry with x64.)
  • Omit info we don't use (e.g. gnu or musl - not applicable because we don't require libc).
  • Don't say unknown since it's implied.
  • Always specify bits explicitly (e.g. x32, not i386, and in the future arm32 over arm).

This also changes the naming scheme for precompiled .rh files to be consistent with this naming system. (As it happens, only x64 targets changed names, so by coincidence the existing tarballs will continue to work on other architectures. This PR includes a backwards compatibility check which special-cases x86_64 as a synonym for x64 in these filenames. Eventually new versions of basic-cli etc will be published with the new filenames, the tutorial will be updated, and this fixup can be removed.)

@@ -1275,83 +1273,3 @@ fn run_wasm<I: Iterator<Item = S>, S: AsRef<[u8]>>(wasm_path: &std::path::Path,
fn run_wasm<I: Iterator<Item = S>, S: AsRef<[u8]>>(_wasm_path: &std::path::Path, _args: I) {
println!("Running wasm files is not supported on this target.");
}

#[derive(Debug, Copy, Clone, EnumIter, IntoStaticStr, PartialEq, Eq, Default)]
pub enum Target {
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved all of this to roc_target, so that it could remove some hardcoded constants which didn't agree with this.

pub const MACOS_X86_64_TARGET_STR: &str = "macos-x86_64";
pub const WINDOWS_X86_64_TARGET_STR: &str = "windows-x86_64";
pub const WINDOWS_X86_32_TARGET_STR: &str = "windows-x86_32";
pub const WIDNOWS_ARM64_TARGET_STR: &str = "windows-arm64";
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants differed from the CLI flags, which meant that .rh files had different names from what was specified on the command line. Now they're consistent, and Target is the single source of truth for these strings.

@rtfeldman rtfeldman force-pushed the linux64 branch 5 times, most recently from 638b87b to 6315c15 Compare June 20, 2023 12:50
rtfeldman and others added 14 commits June 20, 2023 09:23
There's an open design question as to whether we want to commit
to supporting this, so dropping the comment.
This breaks certain use cases of building with --no-link
and an aarch64 target and then linking with lld (via zig cc)
(see "aarch64 linux target" thread on Zulip)

Also it seems to be unnecessary in practice on LLVM 13,
as the comment suggests!
@Anton-4 Anton-4 mentioned this pull request Jul 5, 2023
@rtfeldman rtfeldman merged commit cdb1681 into main Jul 11, 2023
10 checks passed
@rtfeldman rtfeldman deleted the linux64 branch July 11, 2023 16:42
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.

2 participants