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

Support building on Windows with Clang MSVC target #14

Merged
merged 3 commits into from Feb 3, 2021

Conversation

triplef
Copy link
Member

@triplef triplef commented Jan 29, 2021

These changes enable building on Windows with Clang, libobjc2, and the MSVC ABI (i.e. not using MinGW).

Requires using a standard Windows Clang build that e.g. comes with Visual Studio or is available as pre-built binary from the LLVM website. Invoking clang -v should show a target like x86_64-pc-windows-msvc.

Configure must be invoked with a host like x86_64-pc-windows or i386-pc-windows, e.g.:

export CC=/C/LLVM/bin/clang
export CXX=/C/LLVM/bin/clang++
export OBJCXX=/C/LLVM/bin/clang++

./configure --host=x86_64-pc-windows --with-library-combo=ng-gnu-gnu --with-runtime-abi=gnustep-2.0 --prefix=/c/GNUstep/x64 LDFLAGS="-fuse-ld=lld"

As the Windows linker does not support incremental linking using ld -r, this also contains a change to link subproject object files directly (434f957): Instead of merging all subproject object files into subproject.o, we now create a subproject.txt containing a list of all object files, and use these directly in SUBPROJECT_OBJ_FILES. This affects all platforms and seems to work fine in CI for all existing targets, but please let me know if there are any concerns with this change.

Accompanying pull request for Base forthcoming.

Instead of merging all subproject object files into subproject.o, we now create subproject.txt containing a list of all object files, and use these directly in SUBPROJECT_OBJ_FILES.
Fixes checks when $CC is set to something like /path/to/clang.
@triplef triplef requested a review from rfm as a code owner January 29, 2021 12:25
Copy link
Contributor

@rfm rfm left a comment

Choose a reason for hiding this comment

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

That looks really good. I haven't tried it on windows, but I tried it with a few Linux systems without problems.
The only worry I have is about the subproject change: the new mechanism, listing all the obj files, could result in pretty huge command lines. However, the O/S limit on the length of a command line is pretty long nowadays, so I'm not overly concerned by that possibility. I would say that, if it does turn out to be a problem on some systems, we might have to support both mechanisms, but until/unless that turns out to be an issue we shoudl keep it simple and just use your change.

@triplef
Copy link
Member Author

triplef commented Jan 30, 2021

Thanks @rfm, sounds good!

I was also wondering if we should wait with merging this until the upcoming releases are done (not sure what the status on these are)?

@rfm
Copy link
Contributor

rfm commented Feb 2, 2021 via email

@triplef
Copy link
Member Author

triplef commented Feb 3, 2021

Thanks, then I’ll go ahead and merge this.

For future reference, here’s some feedback from David from the mailing list on the possible command line length issue you mentioned. This supports that this is unlikely to be an issue.

  • FreeBSD limits it to 256 KiB on processes with limited kernel virtual address space, 512 KiB elsewhere.
  • Linux limits it to 128KiB statically but can return a larger number via sysconf depending on the system. For me, that is around 2MiB.
  • Windows limits it to 32 KiB, though cmd.exe only handles 8 KiB.

Even with the 8KiB limit, you'd need a few hundred files on the linker invocation for this to be a problem unless you're giving long absolute paths for everything.

@triplef triplef merged commit 49fa068 into master Feb 3, 2021
@triplef triplef deleted the clang-msvc-support branch February 3, 2021 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants