Skip to content

Fix MSVC cross compilation #7079

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged

Conversation

Faless
Copy link
Contributor

@Faless Faless commented May 27, 2025

Currently, the DefaultCFlags.cmake overrides the
CMAKE_STATIC_LINKER_FLAGS to suppress linker warnings about files with no symbols defined.

This has the side effect of breaking MSVC cross compilation (where CMAKE_STATIC_LINKER_FLAGS is used to specify the /MACHINE:ARCH flag)

This commit make sure we append to CMAKE_STATIC_LINKER_FLAGS instead of replacing its values

The error when trying to cross compile with MSVC is the following:

[100%] Linking C static library ..\..\git2.lib
LINK : warning LNK4068: /MACHINE not specified; defaulting to X64
..\util\CMakeFiles\util.dir\alloc.c.obj : fatal error LNK1112: module machine type 'ARM64' conflicts with target machine type 'x64'

Currently, the DefaultCFlags.cmake overrides the
CMAKE_STATIC_LINKER_FLAGS to suppress linker warnings about files with
no symbols defined.

This has the side effect of breaking MSVC cross compilation (where
CMAKE_STATIC_LINKER_FLAGS is used to specify the /MACHINE:ARCH flag)

This commit make sure we append to CMAKE_STATIC_LINKER_FLAGS instead of
replacing its values
@ethomson
Copy link
Member

ethomson commented Jun 4, 2025

Thanks for the fix!

@ethomson ethomson merged commit 488560c into libgit2:main Jun 4, 2025
19 checks passed
@Faless Faless deleted the fix/static_linker_flags branch June 4, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants