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

Compiler detection is incorrect for native LLVM/Clang install on Windows #2560

Open
MarkIngramUK opened this issue Oct 30, 2017 · 9 comments
Labels
compilers help wanted OS:windows Winodows OS specific issues

Comments

@MarkIngramUK
Copy link

ClangCompiler.get_soname_args assumes that Clang on Windows is running under MINGW. It then tries to generate -Wl,-soname options, which are incompatible with Clang 5.0.0.0 running natively on Windows.

CompilerArgs.to_native adds groups via -Wl,--start-group and -Wl,--end-group (as get_compiler_uses_gnuld returns true for Clang on Windows).

CCompiler.gen_import_library_args adds the -Wl,--out-implib option.

CCompiler.build_rpath_args adds the -Wl,-rpath option.

Related options -Wl,--as-needed and -Wl,--no-undefined aren't supported either, but they can be disabled via the b_asneeded and b_lundef flags, respectively.

@nirbheek nirbheek added compilers help wanted OS:windows Winodows OS specific issues labels Nov 29, 2017
@jibsen
Copy link
Contributor

jibsen commented Nov 29, 2017

Native Clang on Windows can target both MSVC and mingw-w64 (I think they started out targeting MinGW, then added support for MSVC, and now MSVC is the default). Clang also supplies clang-cl, a cli that is compatible with MSVC cl.exe.

I've had some issues getting both options to work with CMake on AppVeyor (see for instance the squash AppVeyor script).

So I would love if meson were able to support both.

@xgalaxy
Copy link

xgalaxy commented Mar 11, 2018

Yes. Support for this would be great. Preferably with an option to choose either the GNU compatible (clang/clang++) or the msvc adapter (clang-cl).

@XVilka
Copy link
Contributor

XVilka commented Jun 1, 2018

Ping?

@nirbheek
Copy link
Member

nirbheek commented Jun 1, 2018

Ping?

That only really works for pull requests, not issues. See also, "help wanted" label. ;)

We'd be happy to review a PR that fixes this and adds a test for it so we can properly support GNU clang (easy) and clang-cl (harder).

@barcharcraz
Copy link
Contributor

fwiw, on windows it looks like both "clang" and "clang++" always compile using the msvc abi, the difference is in how they parse arguments and how good they are at figuring out how to link the C library.

You can see this by taking the following program

namespace test {
    void testfunction(int t) {

    }
}
int main(int argc, char** argv) {
    test::testfunction(4);
}

and compiling it with clang++ -c test.cpp on windows. then looking at test.o in dumpbin or similar, if you see ?testfunction@test@@YAXH@Z then clang is compiling with MSVC ABI

if you compile with clang++ -c -target x86_64-pc-windows-gnu test.cpp you should instead see _ZN4test12testfunctionEi

@barcharcraz
Copy link
Contributor

note that it's likely that if you configure/build clang with gcc on windows or with gcc on unix targeting windows then you'll get a clang.exe that defaults to x86_64-pc-windows-gnu!

@barcharcraz
Copy link
Contributor

AND if you have visual studio installed you may have a version of clang that's neither of these and that is the clang parser with C2 (microsoft's backend) output!!!! For all intents this should be similar to clang with x86_64-pc-windows-msvc

@dcbaker
Copy link
Member

dcbaker commented Nov 17, 2018

@jon-turney, is this closable now?

@jon-turney
Copy link
Member

Not yet fixed. Possibly a duplicate of #4232, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilers help wanted OS:windows Winodows OS specific issues
Projects
None yet
Development

No branches or pull requests

8 participants