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

ARM/AArch64 cross-compilation targets aren't respected in an MSVC environment on Windows. #4624

Open
just-harry opened this issue Apr 21, 2024 · 2 comments

Comments

@just-harry
Copy link
Contributor

In a fully set-up MSVC environment (e.g. an environment set-up by Visual Studio's vcvarsall.bat) with a target of AArch64 ($Env:VSCMD_ARG_TGT_ARCH == arm64) or ARM ($Env:VSCMD_ARG_TGT_ARCH == arm), LDC will set-up an MSVC environment for x86-64 or x86, even if the -mtriple supplied to LDC is aarch64-windows or arm-windows (for example).

This results in the wrong libraries being supplied to the linker, and C files being preprocessed for the wrong target when cl is used for preprocessing.

This seems to be because setupMsvcEnvironmentImpl expects only x64 or x86 for the VSCMD_ARG_TGT_ARCH environment variable:

ldc/driver/tool.cpp

Lines 295 to 300 in b75fc4c

// Assume a fully set up environment (e.g., VS native tools command prompt).
// Skip the MSVC setup unless the environment is set up for a different
// target architecture.
const auto tgtArch = env::get("VSCMD_ARG_TGT_ARCH"); // VS 2017+
if (tgtArch.empty() || tgtArch == (x64 ? "x64" : "x86"))
return true;

@just-harry
Copy link
Contributor Author

A proposed fix: #4625

@kinke
Copy link
Member

kinke commented Apr 30, 2024

#4625 fixed this partially - an already set-up MSVC environment for ARM targets should work now, but setting it up manually would require more work, e.g., in function https://github.com/dlang/dmd/blob/748fab1e02b9f9e8980833b79e9448937bfecfab/compiler/src/dmd/vsoptions.d#L380.

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