{"thread":{"id":"50425","subject":"[PATCH 0/1] Fix incorrectly reported CPU in 32-bit Windows","startedAt":"2019-02-07T10:46:09Z","lastAt":"2019-02-13T10:00:16Z","messageCount":6,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano","Johannes Schindelin","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"368699","messageId":"pull.121.git.gitgitgadget@gmail.com","threadId":"50425","inReplyTo":null,"subject":"[PATCH 0/1] Fix incorrectly reported CPU in 32-bit Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-02-07T10:46:05Z","receivedAt":"2019-02-07T10:46:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"While in review, Git for Windows' original design was changed, to use the\noutput of uname -m instead of (necessarily incomplete) pre-processor magic\nto determine which CPU to report.\n\nBoth 32-bit and 64-bit versions of Git for Windows are built in the 64-bit\nGit for Windows SDK, however, whose uname -m always reports x86_64. Even for\n32-bit Git for Windows.\n\nLet's fix that by going back to the pre-processor magic, making it specific\nto Git for Windows' SDK (where it actually is complete).\n\nThis is yet another patch I forgot to upstream, and I hope that it will make\nit into v2.21.0-rc1.\n\nJohannes Schindelin (1):\n  mingw: fix CPU reporting in `git version --build-options`\n\n compat/mingw.h | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\n\nbase-commit: d62dad7a7dca3f6a65162bf0e52cdf6927958e78\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-121%2Fdscho%2Fmingw-build-options-fix-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-121/dscho/mingw-build-options-fix-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/121\n-- \ngitgitgadget\n"},{"id":"368700","messageId":"cca9a543d52f3d7d9015709800e10ea57be1fea3.1549536364.git.gitgitgadget@gmail.com","threadId":"50425","inReplyTo":"pull.121.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] mingw: fix CPU reporting in `git version --build-options`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-02-07T10:46:06Z","receivedAt":"2019-02-07T10:46:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWe cannot rely on `uname -m` in Git for Windows' SDK to tell us what\narchitecture we are compiling for, as we can compile both 32-bit and\n64-bit `git.exe` from a 64-bit SDK, but the `uname -m` in that SDK will\nalways report `x86_64`.\n\nSo let's go back to our original design. And make it explicitly\nWindows-specific.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n compat/mingw.h | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 30d9fb3e36..98407744f2 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -6,6 +6,25 @@ typedef _sigset_t sigset_t;\n #include <winsock2.h>\n #include <ws2tcpip.h>\n \n+#ifdef __MINGW64_VERSION_MAJOR\n+/*\n+ * In Git for Windows, we cannot rely on `uname -m` to report the correct\n+ * architecture: /usr/bin/uname.exe will report the architecture with which the\n+ * current MSYS2 runtime was built, not the architecture for which we are\n+ * currently compiling (both 32-bit and 64-bit `git.exe` is built in the 64-bit\n+ * Git for Windows SDK).\n+ */\n+#undef GIT_HOST_CPU\n+/* This was figured out by looking at `cpp -dM </dev/null`'s output */\n+#if defined(__x86_64__)\n+#define GIT_HOST_CPU \"x86_64\"\n+#elif defined(__i686__)\n+#define GIT_HOST_CPU \"i686\"\n+#else\n+#error \"Unknown architecture\"\n+#endif\n+#endif\n+\n /* MinGW-w64 reports to have flockfile, but it does not actually have it. */\n #ifdef __MINGW64_VERSION_MAJOR\n #undef _POSIX_THREAD_SAFE_FUNCTIONS\n-- \ngitgitgadget\n"},{"id":"368739","messageId":"xmqq36oznvxs.fsf@gitster-ct.c.googlers.com","threadId":"50425","inReplyTo":"pull.121.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/1] Fix incorrectly reported CPU in 32-bit Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-07T21:13:51Z","receivedAt":"2019-02-07T21:13:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> This is yet another patch I forgot to upstream, and I hope that it will make\n> it into v2.21.0-rc1.\n\nI guess this affects nobody other than you and perhaps J6t, the\npoint not being \"there are only just two\" but being \"all of them\nknow how to deal with possible breakages if any in this change\".\n\nI am tempted to bypass the usual \"from pu down to next down to\nmaster\" dance on this one, because of that.\n\n;-)\n\n"},{"id":"368751","messageId":"nycvar.QRO.7.76.6.1902072340430.41@tvgsbejvaqbjf.bet","threadId":"50425","inReplyTo":"xmqq36oznvxs.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 0/1] Fix incorrectly reported CPU in 32-bit Windows","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-02-07T22:41:35Z","receivedAt":"2019-02-07T22:41:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Thu, 7 Feb 2019, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n> \n> > This is yet another patch I forgot to upstream, and I hope that it\n> > will make it into v2.21.0-rc1.\n> \n> I guess this affects nobody other than you and perhaps J6t, the\n> point not being \"there are only just two\" but being \"all of them\n> know how to deal with possible breakages if any in this change\".\n\nCorrect. This patch is already in Git for Windows, so contributors\nbuilding from that fork will have had the problem already.\n\n> I am tempted to bypass the usual \"from pu down to next down to\n> master\" dance on this one, because of that.\n> \n> ;-)\n\nI would be very grateful for that :-)\n\nCiao,\nDscho\n"},{"id":"368897","messageId":"CAPig+cRPEoro_661Py+6RDTGvZdT4gAVK45jAuGr+g_Rt=en6A@mail.gmail.com","threadId":"50425","inReplyTo":"cca9a543d52f3d7d9015709800e10ea57be1fea3.1549536364.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] mingw: fix CPU reporting in `git version --build-options`","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-02-08T22:39:53Z","receivedAt":"2019-02-08T22:40:06Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Feb 7, 2019 at 5:46 AM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> We cannot rely on `uname -m` in Git for Windows' SDK to tell us what\n> architecture we are compiling for, as we can compile both 32-bit and\n> 64-bit `git.exe` from a 64-bit SDK, but the `uname -m` in that SDK will\n> always report `x86_64`.\n>\n> So let's go back to our original design. And make it explicitly\n> Windows-specific.\n\nb22894049f (version --build-options: also report host CPU, 2017-12-15)\ntook this sort of case into consideration by introducing Makefile\nvariable HOST_CPU (which takes precedence over `uname -m`), with the\nintention that, when cross-compiling, your build environment should\n(somehow) set HOST_CPU to the canonical name of the CPU on which the\nbuilt Git will run (for instance, \"x86_64\" or \"i686\"). It would be\nnice to employ this mechanism to solve this issue rather than\n(re-)introducing a manually-maintained list of CPU names.\n\nCan you say a few words (here in the email thread) about how the Git\nfor Windows SDK is instructed to build for one architecture or the\nother? With such information, perhaps we can figure out how to get the\nbuild environment itself to set HOST_CPU automatically so we don't\nhave to resort to and worry about maintenance costs of a hard-coded\nCPU name list.\n\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n> diff --git a/compat/mingw.h b/compat/mingw.h\n> @@ -6,6 +6,25 @@ typedef _sigset_t sigset_t;\n> +#ifdef __MINGW64_VERSION_MAJOR\n> +/*\n> + * In Git for Windows, we cannot rely on `uname -m` to report the correct\n> + * architecture: /usr/bin/uname.exe will report the architecture with which the\n> + * current MSYS2 runtime was built, not the architecture for which we are\n> + * currently compiling (both 32-bit and 64-bit `git.exe` is built in the 64-bit\n> + * Git for Windows SDK).\n> + */\n> +#undef GIT_HOST_CPU\n> +/* This was figured out by looking at `cpp -dM </dev/null`'s output */\n> +#if defined(__x86_64__)\n> +#define GIT_HOST_CPU \"x86_64\"\n> +#elif defined(__i686__)\n> +#define GIT_HOST_CPU \"i686\"\n> +#else\n> +#error \"Unknown architecture\"\n> +#endif\n> +#endif\n"},{"id":"369216","messageId":"nycvar.QRO.7.76.6.1902131046300.41@tvgsbejvaqbjf.bet","threadId":"50425","inReplyTo":"CAPig+cRPEoro_661Py+6RDTGvZdT4gAVK45jAuGr+g_Rt=en6A@mail.gmail.com","subject":"Re: [PATCH 1/1] mingw: fix CPU reporting in `git version --build-options`","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-02-13T09:59:50Z","receivedAt":"2019-02-13T10:00:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Fri, 8 Feb 2019, Eric Sunshine wrote:\n\n> On Thu, Feb 7, 2019 at 5:46 AM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > We cannot rely on `uname -m` in Git for Windows' SDK to tell us what\n> > architecture we are compiling for, as we can compile both 32-bit and\n> > 64-bit `git.exe` from a 64-bit SDK, but the `uname -m` in that SDK will\n> > always report `x86_64`.\n> >\n> > So let's go back to our original design. And make it explicitly\n> > Windows-specific.\n> \n> b22894049f (version --build-options: also report host CPU, 2017-12-15)\n> took this sort of case into consideration by introducing Makefile\n> variable HOST_CPU (which takes precedence over `uname -m`), with the\n> intention that, when cross-compiling, your build environment should\n> (somehow) set HOST_CPU to the canonical name of the CPU on which the\n> built Git will run (for instance, \"x86_64\" or \"i686\"). It would be\n> nice to employ this mechanism to solve this issue rather than\n> (re-)introducing a manually-maintained list of CPU names.\n\nHeh, this is also manually-maintained, but I agree that it is cleaner.\n\n> Can you say a few words (here in the email thread) about how the Git\n> for Windows SDK is instructed to build for one architecture or the\n> other?\n\nTo cross-compile a 32-bit Git in a 64-bit Git for Windows SDK, use this\nincantation:\n\n\tMSYSTEM=MINGW32 PATH=/mingw32/bin:$PATH make\n\n> With such information, perhaps we can figure out how to get the build\n> environment itself to set HOST_CPU automatically so we don't have to\n> resort to and worry about maintenance costs of a hard-coded CPU name\n> list.\n\nIndeed, we can set HOST_CPU in the same conditionals as prefix (which is\n/mingw32 for 32-bit and /mingw64 for 64-bit) in config.mak.uname.\n\nPatch incoming,\nDscho\n\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> > diff --git a/compat/mingw.h b/compat/mingw.h\n> > @@ -6,6 +6,25 @@ typedef _sigset_t sigset_t;\n> > +#ifdef __MINGW64_VERSION_MAJOR\n> > +/*\n> > + * In Git for Windows, we cannot rely on `uname -m` to report the correct\n> > + * architecture: /usr/bin/uname.exe will report the architecture with which the\n> > + * current MSYS2 runtime was built, not the architecture for which we are\n> > + * currently compiling (both 32-bit and 64-bit `git.exe` is built in the 64-bit\n> > + * Git for Windows SDK).\n> > + */\n> > +#undef GIT_HOST_CPU\n> > +/* This was figured out by looking at `cpp -dM </dev/null`'s output */\n> > +#if defined(__x86_64__)\n> > +#define GIT_HOST_CPU \"x86_64\"\n> > +#elif defined(__i686__)\n> > +#define GIT_HOST_CPU \"i686\"\n> > +#else\n> > +#error \"Unknown architecture\"\n> > +#endif\n> > +#endif\n> \n"}]}