Skip to content

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