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

cmake(): allow setting HOST_CPU for cross-compilation #3327

Merged
merged 2 commits into from
Jul 19, 2021

Conversation

dennisameling
Copy link

@dennisameling dennisameling commented Jul 19, 2021

Related to #3107

As reported by @rimrul in #3083 (comment), git version --build-options returns the wrong CPU when building Git for ARM64 Windows.

Git's regular Makefile mentions that HOST_CPU should be defined when cross-compiling Git:

git/Makefile

Lines 438 to 439 in 37796bc

# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
# which the built Git will run (for instance "x86_64").

This is then used to set the GIT_HOST_CPU variable when compiling Git:

git/Makefile

Lines 1337 to 1341 in 37796bc

ifeq (,$(HOST_CPU))
BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(firstword $(subst -, ,$(uname_M)))\""
else
BASIC_CFLAGS += -DGIT_HOST_CPU="\"$(HOST_CPU)\""
endif

Then, when the user runs git version --build-options, it returns that value:

git/help.c

Line 658 in 37796bc

strbuf_addf(buf, "cpu: %s\n", GIT_HOST_CPU);

This PR adds the same functionality to the CMake configuration. Users can now set -DHOST_CPU= to set the target architecture.

I split this into 2 separate commits, since .github/git-artifacts.yml is Git for Windows-specific and therefore can't be upstreamed.

Artifacts run: https://github.com/dennisameling/git/actions/runs/1044960096 (note that this only applies to Git for Windows arm64 since the other architectures are still built using the original Makefile)

Git's regular Makefile mentions that HOST_CPU should be defined when cross-compiling Git: https://github.com/git-for-windows/git/blob/37796bca76ef4180c39ee508ca3e42c0777ba444/Makefile#L438-L439

This is then used to set the GIT_HOST_CPU variable when compiling Git: https://github.com/git-for-windows/git/blob/37796bca76ef4180c39ee508ca3e42c0777ba444/Makefile#L1337-L1341

Then, when the user runs `git version --build-options`, it returns that value: https://github.com/git-for-windows/git/blob/37796bca76ef4180c39ee508ca3e42c0777ba444/help.c#L658

This commit adds the same functionality to the CMake configuration. Users can now set -DHOST_CPU= to set the target architecture.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
As mentioned in the Makefile and CMakeLists.txt: "When cross-compiling, define HOST_CPU as the canonical name of the CPU on which the built Git will run (for instance "x86_64")"

This commit sets the HOST_CPU variable since Git for Windows arm64 is cross-compiled from an amd64 host.

Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
@dscho
Copy link
Member

dscho commented Jul 19, 2021

No worries about the macOS failures, I opened Homebrew/homebrew-cask#108819 which will hopefully soon be merged (and should fix this issue).

@dscho dscho merged commit b6e53ed into git-for-windows:main Jul 19, 2021
@dscho
Copy link
Member

dscho commented Jul 19, 2021

Thank you @dennisameling!

git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Jul 19, 2021
cmake(): allow setting HOST_CPU for cross-compilation
@dennisameling dennisameling deleted the fix-host-cpu branch July 20, 2021 10:25
git-for-windows-ci pushed a commit that referenced this pull request Jul 20, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 21, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 21, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 22, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2021
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Jul 23, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 23, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 24, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 24, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 24, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 26, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 28, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 28, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Jul 29, 2021
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 9, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 9, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 9, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 10, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 10, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 10, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 11, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 11, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 11, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 11, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 20, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 20, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 21, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 21, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 21, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 22, 2024
cmake(): allow setting HOST_CPU for cross-compilation
dscho added a commit that referenced this pull request Oct 23, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 25, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Oct 30, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Nov 1, 2024
cmake(): allow setting HOST_CPU for cross-compilation
git-for-windows-ci pushed a commit that referenced this pull request Nov 6, 2024
cmake(): allow setting HOST_CPU for cross-compilation
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

Successfully merging this pull request may close these issues.

2 participants