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

Initial pass at supporting nasm #536

Closed
wants to merge 2 commits into from

Conversation

Jake-Shadle
Copy link
Contributor

When targetting the Windows msvc environment, cc currently assumes you are compiling on a Windows host and attempts to find specifically named assemblers based on the target architecture when compiling .asm files, which obviously doesn't work great when you aren't on a windows host. This adds initial support for having a AS environment variable where the user can specify the assembler they actually want to use, with explicit support for nasm, which can assemble x86 and x86_64 windows targets from windows and non-windows hosts.

@alexcrichton
Copy link
Member

Thanks for this! I presume though that the syntaxes for nasm/windows are probably incompatible? If that's the case does an env var make sense for this if it's something that always has to be configured?

Additionally would it be possible to add a test or two to CI for this?

@Jake-Shadle
Copy link
Contributor Author

Yes, unfortunately the syntaxes are incompatible so it's not a drop in replacement, which is why I added this as a draft at first.

Thinking a bit more on it, maybe it would be better to just have a convenient mechanism off of Build or possibly Tool that can tell the user "I want Microsoft assembly" vs eg GAS, as I've fixed up several crates that have both Microsoft and GAS for targeting windows with either MSVC or GNU environments (though definitely not all), but they end up writing incorrect build scripts that only take TARGET and not HOST into account, as when cross compiling with clang-cl, it's the MSVC compiler from the perspective of cc-rs, but they need to use the GAS files instead of the MASM ones since the Microsoft assemblers aren't available.

Ultimately, it would be nice if clang/LLVM added support for MASM, I'm just not going to hold my breath. https://bugs.chromium.org/p/chromium/issues/detail?id=762167

@alexcrichton
Copy link
Member

Hm ok, well if it's a syntactical thing it seems like that should be an API on Build rather than an env var, but otherwise w/e is needed to compile nasm seems ok by me.

@thomcc thomcc added the O-windows Windows targets and toolchains label Oct 26, 2022
@ChrisDenton
Copy link
Member

@Jake-Shadle are you still wanting to work on this or is the new llvm-ml a solution?

@Jake-Shadle
Copy link
Contributor Author

Is that actually official now? I should have closed this regardless, most projects that have asm also have a GAS version for windows-pc-gnu so needing to cross compile masm is rarely an issue.

@Jake-Shadle Jake-Shadle closed this Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Windows targets and toolchains
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants