Hot fixes from Git for Windows v2.49.0-rc0
cover Hot fixes from Git for Windows v2.49.0-rc0
I needed many patches to make Git for Windows v2.49.0-rc0 compile and run the many, many CI jobs successfully. These here patches even apply to upstream Git. (Technically, the Meson sorting patch is not required to compile, but it was the fall-out from many required adjustments to make the Meson jobs happy.)
Johannes Schindelin (2):
ident: stop assuming that gw_gecos is writable
meson: fix sorting
ident.c | 2 +- meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
base-commit: b838bf1938926a7a900166136d995d86f8a00e24
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1867%2Fdscho%2Fg4w-hot-fixes-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1867/dscho/g4w-hot-fixes-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1867
Signature · 1 line
gitgitgadget
PATCH 1/2 ident: stop assuming that `gw_gecos` is writable
From: Johannes Schindelin <[email protected]>
In 590e081dea7c (ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd, 2011-05-19), code was introduced to iterate over the gw_gecos field; The loop variable is of type char *, which assumes that gw_gecos is writable.
However, it is not necessarily writable (and it is a bad idea to have it writable in the first place), so let's switch the loop variable type to const char *.
--- ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ident.c +1 -1
@@ -59,7 +59,7 @@ static struct passwd *xgetpwuid_self(int *is_bogus)static void copy_gecos (const struct passwd *w,struct strbuf *name) { -char *src; +const char *src;/* Traditionally GECOS field had office phone numbers etc, separated * with commas. Also & stands for capitalized form of the login name.
Signature · 1 line
gitgitgadget
Re: [PATCH 1/2] ident: stop assuming that `gw_gecos` is writable
"Johannes Schindelin via GitGitGadget" <[email protected]>
Quoted 7 lines · writes:
From: Johannes Schindelin <[email protected]>
In
590e081dea7c(ident: addNO_GECOS_IN_PWENTfor systems withoutpw_gecosin struct passwd, 2011-05-19), code was introduced to iterate over thegw_gecosfield; The loop variable is of typechar *, which assumes thatgw_gecosis writable.
Quoted 8 lines
However, it is not necessarily writable (and it is a bad idea to have it writable in the first place), so let's switch the loop variable type to
const char *.Signed-off-by Johannes Schindelin <[email protected]>--- ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Can we have a bit more details here (not in the commit but after the three-dash line, meant for context) why the change from 2011 needs a "hotfix" today? Has something in the build environment change? An updated header file has changed definition for "struct passwd", or something silly like that? Even though POSIX.1 does not define gecos in its struct passwd in <pwd.h>, other string members like pw_name and pw_dir are writable, which I found funny, and makes me puzzled why this code from 2011 needs a hotfix all of the sudden.
ident.c static struct passwd *xgetpwuid_self(int *is_bogus) · line 65
Quoted 13 lines
ident.c +1
-1@@ -59,7 +59,7 @@ static struct passwd *xgetpwuid_self(int *is_bogus)static void copy_gecos (const struct passwd *w,struct strbuf *name) { -char *src; +const char *src;/* Traditionally GECOS field had office phone numbers etc, separated * with commas. Also & stands for capitalized form of the login name.
The patch text itself looks perfectly fine, so I am not opposed to its eventual application. Even though we do declare "src" as non-const, we only use it to read from it, so declaring it as const pointer is perfectly fine and more appropriate.
But I do not see any urgency relative to Git 2.48.0 (or Git 2.48.1 for that matter) to mark this as "hotfix" implying that it should be included in 2.49-rc1 in either the patch or the proposed commit log message.
Thanks.
PATCH 2/2 meson: fix sorting
In reply to Johannes Schindelin via GitGitGadgetFrom: Johannes Schindelin <[email protected]>
In 904339edbd80 (Introduce support for the Meson build system, 2024-12-06) the meson.build file was introduced, adding also a Windows-specific list of source files. This list was obviously meant to be sorted alphabetically, but there is one mistake. Let's fix that.
--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
@@ -1092,11 +1092,11 @@ elif host_machine.system() == 'windows' libgit_sources += [ 'compat/mingw.c', 'compat/winansi.c', + 'compat/win32/dirent.c', 'compat/win32/flush.c', 'compat/win32/path-utils.c', 'compat/win32/pthread.c', 'compat/win32/syslog.c', - 'compat/win32/dirent.c', 'compat/win32mmap.c', 'compat/nedmalloc/nedmalloc.c', ]
Signature · 1 line
gitgitgadget
Re: [PATCH 2/2] meson: fix sorting
Quoted 6 lines · Johannes Schindelin via GitGitGadget
From: Johannes Schindelin <[email protected]>
In
904339edbd80(Introduce support for the Meson build system, 2024-12-06) themeson.buildfile was introduced, adding also a Windows-specific list of source files. This list was obviously meant to be sorted alphabetically, but there is one mistake. Let's fix that.
This looks obviously good to me, thanks!
Patrick
v2 cover Hot fixes from Git for Windows v2.49.0-rc0
In reply to Johannes Schindelin via GitGitGadgetI needed many patches to make Git for Windows v2.49.0-rc0 compile and run the many, many CI jobs successfully. These here patches even apply to upstream Git. (Technically, the Meson sorting patch is not required to compile, but it was the fall-out from many required adjustments to make the Meson jobs happy.)
Changes since v1:
* I spent two hours investigating under which circumstances the (correct) compiler error about a non-writable pw_gecos field triggers, and augmented the commit message accordingly.
* Since -rc1, another breaking change necessitated yet another hot fix, which I invites to this patch fest (and the patch series hence had to be rebased to the current tip of Git's main branch).
Johannes Schindelin (3):
ident: stop assuming that gw_gecos is writable
meson: fix sorting
cmake: generalize the handling of the CLAR_TEST_OBJS list
contrib/buildsystems/CMakeLists.txt | 12 ++++++++---- ident.c | 2 +- meson.build | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-)
base-commit: e969bc875963a10890d61ba84eab3a460bd9e535
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1867%2Fdscho%2Fg4w-hot-fixes-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1867/dscho/g4w-hot-fixes-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1867
Range-diff vs v1:
1: 045c11dc1d5 ! 1: 3e9ccffc747 ident: stop assuming that gw_gecos is writable
@@ Commit message
writable in the first place), so let's switch the loop variable type to const char *.
+ This is not a new problem, but what is new is the Meson build. While it
+ does not trigger in CI builds, imitating the commands of
+ ci/run-build-and-tests.sh in a regular Git for Windows SDK (`meson
+ setup build . --fatal-meson-warnings --warnlevel 2 --werror --wrap-mode
+ nofallback -Dfuzzers=true followed by meson compile -C build --`
+ results in this beautiful error:
+
+ "cc" [...] -o libgit.a.p/ident.c.obj "-c" ../ident.c
+ ../ident.c: In function 'copy_gecos':
+ ../ident.c:68:18: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
+ 68 | for (src = get_gecos(w); *src && *src != ','; src++) {
+ | ^
+ cc1.exe: all warnings being treated as errors
+
+ Now, why does this not trigger in CI? The answer is as simple as it is
+ puzzling: The win+Meson job completely side-steps Git for Windows'
+ development environment, opting instead to use the GCC that is on the
+ PATH in GitHub-hosted windows-latest runners. That GCC is pinned to
+ v12.2.0 and targets the UCRT (unlikely to change any time soon, see
+ https://github.com/actions/runner-images/blob/win25/20250303.1/images/windows/toolsets/toolset-2022.json#L132-L141).
+ That is in stark contrast to Git for Windows, which uses GCC v14.2.0 and
+ targets MSVCRT. Git for Windows' Makefile-based build also obviously
+ uses different compiler flags, otherwise this compile error would have
+ had plenty of opportunity in almost 14 years to surface.
+
+ In other words, contrary to my expectations, the win+Meson job is
+ ill-equipped to replace the win build job because it exercises a
+ completely different tool version/compiler flags vector than what Git
+ for Windows needs.
+
+ Nevertheless, there is currently this huge push, including breaking
+ changes after -rc1 and all, for switching to Meson. Therefore, we need
+ to make it work, somehow, even in Git for Windows' SDK, hence this
+ patch, at this point in time.
+
## ident.c ##
2: 9d1faeae8a4 = 2: 4e9ab3e011f meson: fix sorting -: ----------- > 3: 59a2e586e1a cmake: generalize the handling of the `CLAR_TEST_OBJS` list
Signature · 1 line
gitgitgadget
PATCH v2 1/3 ident: stop assuming that `gw_gecos` is writable
From: Johannes Schindelin <[email protected]>
In 590e081dea7c (ident: add NO_GECOS_IN_PWENT for systems without pw_gecos in struct passwd, 2011-05-19), code was introduced to iterate over the gw_gecos field; The loop variable is of type char *, which assumes that gw_gecos is writable.
However, it is not necessarily writable (and it is a bad idea to have it writable in the first place), so let's switch the loop variable type to const char *.
This is not a new problem, but what is new is the Meson build. While it does not trigger in CI builds, imitating the commands of ci/run-build-and-tests.sh in a regular Git for Windows SDK (meson setup build . --fatal-meson-warnings --warnlevel 2 --werror --wrap-mode nofallback -Dfuzzers=true followed by meson compile -C build -- results in this beautiful error:
"cc" [...] -o libgit.a.p/ident.c.obj "-c" ../ident.c
../ident.c: In function 'copy_gecos':
../ident.c:68:18: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
68 | for (src = get_gecos(w); *src && *src != ','; src++) {
| ^cc1.exe: all warnings being treated as errors
Now, why does this not trigger in CI? The answer is as simple as it is
puzzling: The win+Meson job completely side-steps Git for Windows' development environment, opting instead to use the GCC that is on the PATH in GitHub-hosted windows-latest runners. That GCC is pinned to v12.2.0 and targets the UCRT (unlikely to change any time soon, see
https://github.com/actions/runner-images/blob/win25/20250303.1/images/windows/toolsets/toolset-2022.json#L132-L141).
That is in stark contrast to Git for Windows, which uses GCC v14.2.0 and targets MSVCRT. Git for Windows' Makefile-based build also obviously uses different compiler flags, otherwise this compile error would have had plenty of opportunity in almost 14 years to surface.
In other words, contrary to my expectations, the win+Meson job is ill-equipped to replace the win build job because it exercises a completely different tool version/compiler flags vector than what Git for Windows needs.
Nevertheless, there is currently this huge push, including breaking changes after -rc1 and all, for switching to Meson. Therefore, we need to make it work, somehow, even in Git for Windows' SDK, hence this patch, at this point in time.
--- ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ident.c +1 -1
@@ -59,7 +59,7 @@ static struct passwd *xgetpwuid_self(int *is_bogus)static void copy_gecos (const struct passwd *w,struct strbuf *name) { -char *src; +const char *src;/* Traditionally GECOS field had office phone numbers etc, separated * with commas. Also & stands for capitalized form of the login name.
Signature · 1 line
gitgitgadget
Re: [PATCH v2 1/3] ident: stop assuming that `gw_gecos` is writable
Quoted 11 lines · Johannes Schindelin via GitGitGadget
From: Johannes Schindelin <[email protected]>
Now, why does this not trigger in CI? The answer is as simple as it is
puzzling: Thewin+Mesonjob completely side-steps Git for Windows' development environment, opting instead to use the GCC that is on thePATHin GitHub-hostedwindows-latestrunners. That GCC is pinned to v12.2.0 and targets the UCRT (unlikely to change any time soon, see
https://github.com/actions/runner-images/blob/win25/20250303.1/images/windows/toolsets/toolset-2022.json#L132-L141).
That is in stark contrast to Git for Windows, which uses GCC v14.2.0 and targets MSVCRT. Git for Windows'Makefile-based build also obviously uses different compiler flags, otherwise this compile error would have had plenty of opportunity in almost 14 years to surface.
Oh, interesting. I didn't even know that the Windows runners had GCC in their PATH, and thus I didn't expect it to use that compiler at all. On GitLab for example we can see that it uses the MSVC compiler as I did expect [1]:
Activating VS 17.10.2
C compiler for the host machine: cl (msvc 19.40.33811 "Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64")
C linker for the host machine: link link 14.40.33811.0But you're right, on GitHub that's not the case:
C compiler for the host machine: gcc (gcc 12.2.0 "gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 12.2.0") C linker for the host machine: gcc ld.bfd 2.39
We can easily fix that by passing the --vsenv flag to Meson. I'll send a patch soonish.
Patrick
[1]: https://gitlab.com/gitlab-org/git/-/jobs/9324989037#L95
[2]: https://github.com/git/git/actions/runs/13686408338/job/38270746786#step:5:15
Re: [PATCH v2 1/3] ident: stop assuming that `gw_gecos` is writable
Hi Patrick,
Quoted 27 lines · Patrick Steinhardt
Quoted 11 lines · Johannes Schindelin via GitGitGadget
From: Johannes Schindelin <[email protected]>
Now, why does this not trigger in CI? The answer is as simple as it is
puzzling: Thewin+Mesonjob completely side-steps Git for Windows' development environment, opting instead to use the GCC that is on thePATHin GitHub-hostedwindows-latestrunners. That GCC is pinned to v12.2.0 and targets the UCRT (unlikely to change any time soon, see
https://github.com/actions/runner-images/blob/win25/20250303.1/images/windows/toolsets/toolset-2022.json#L132-L141).
That is in stark contrast to Git for Windows, which uses GCC v14.2.0 and targets MSVCRT. Git for Windows'Makefile-based build also obviously uses different compiler flags, otherwise this compile error would have had plenty of opportunity in almost 14 years to surface.Oh, interesting. I didn't even know that the Windows runners had GCC in their PATH, and thus I didn't expect it to use that compiler at all. On GitLab for example we can see that it uses the MSVC compiler as I did expect [1]:
Activating VS 17.10.2 C compiler for the host machine: cl (msvc 19.40.33811 "Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64") C linker for the host machine: link link 14.40.33811.0But you're right, on GitHub that's not the case:
C compiler for the host machine: gcc (gcc 12.2.0 "gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 12.2.0") C linker for the host machine: gcc ld.bfd 2.39
Quoted 7 lines
We can easily fix that by passing the
--vsenvflag to Meson. I'll send a patch soonish.Patrick
[1]: https://gitlab.com/gitlab-org/git/-/jobs/9324989037#L95
[2]: https://github.com/git/git/actions/runs/13686408338/job/38270746786#step:5:15
Please do not invest more time on the Visual Studio support via Meson. No contributor will use this, and I want to stop spending my time on this. The user experience of configuring a Visual Studio build via Meson is just too weak compared to the ease of CMake-based builds, and while not many Visual Studio users are familiar with CMake, even dramatically less will even so much as know about Meson.
I plan on dropping all pretense that Git supports Visual Studio-based contributions soon after v2.49.0 comes out, e.g. by deleting the CMake definition and also deleting whatever Meson-specific stuff I can get away deleting in Git for Windows. It was not worth the time I invested.
Ciao,
Johannes
Re: [PATCH v2 1/3] ident: stop assuming that `gw_gecos` is writable
In reply to Johannes Schindelin via GitGitGadget"Johannes Schindelin via GitGitGadget" <[email protected]>
Quoted 4 lines · writes:
In other words, contrary to my expectations, the
win+Mesonjob is ill-equipped to replace thewin buildjob because it exercises a completely different tool version/compiler flags vector than what Git for Windows needs.
It is apparent that meson support is a new procedure to build our codebase that is untested and unproven on Windows at all, given that among all people who may have stake in Windows you are discovering problems in it this late in the cycle. Nobody knows what other breakages, other than something obvious and easy to catch like "ah, compiler refuses to go further", are lurking under the radar.
I would be reluctant to trust the build artifact out of meson-based build on Windows after seeing your report, especially the above part.
A reasonable alternative may be to declare that meson-based build is not ready yet at this point, and possibly disable win+Meson jobs to punt and divert our engineering resources elsewhere in the meantime. For a new thing, having an uneven support depending on the platform early in the evolution is not unusual or to be ashamed of.
Quoted 4 lines
Nevertheless, there is currently this huge push, including breaking changes after -rc1 and all, for switching to Meson. Therefore, we need to make it work, somehow, even in Git for Windows' SDK, hence this patch, at this point in time.
As I said earlier already, I do not mind turning the type of this pointer, which is only used to read from a struct member, like this patch does. It is the right thing to do, so I'll apply.
But I personally would not be comfortable with the product built with "completely different tool version/compiler flags vector than what G4W needs", even the compilation passes with just this small change. If I were using Windows, that is.
Quoted 4 lines
Signed-off-by Johannes Schindelin <[email protected]>--- ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks, will apply.
Quoted 13 lines
ident.c +1
-1@@ -59,7 +59,7 @@ static struct passwd *xgetpwuid_self(int *is_bogus)static void copy_gecos (const struct passwd *w,struct strbuf *name) { -char *src; +const char *src;/* Traditionally GECOS field had office phone numbers etc, separated * with commas. Also & stands for capitalized form of the login name.
Re: [PATCH v2 1/3] ident: stop assuming that `gw_gecos` is writable
Quoted 19 lines · Junio C Hamano
"Johannes Schindelin via GitGitGadget" <[email protected]>
Quoted 4 lines · writes:
In other words, contrary to my expectations, the
win+Mesonjob is ill-equipped to replace thewin buildjob because it exercises a completely different tool version/compiler flags vector than what Git for Windows needs.It is apparent that meson support is a new procedure to build our codebase that is untested and unproven on Windows at all, given that among all people who may have stake in Windows you are discovering problems in it this late in the cycle. Nobody knows what other breakages, other than something obvious and easy to catch like "ah, compiler refuses to go further", are lurking under the radar.
I would be reluctant to trust the build artifact out of meson-based build on Windows after seeing your report, especially the above part.
Quoted 5 lines
A reasonable alternative may be to declare that meson-based build is not ready yet at this point, and possibly disable win+Meson jobs to punt and divert our engineering resources elsewhere in the meantime. For a new thing, having an uneven support depending on the platform early in the evolution is not unusual or to be ashamed of.
I think it would be a bit sad to disable those jobs. They build and pass the test suite alright in Git itself, even though they fail downstream in Git for Windows. They help me quite a bit to ensure that I don't regress anything that already is working while I'm iterating on the current set of features. So in the end, I view them more as testing more variants of Windows than replacing what we currently have, similar to how we test Git on different Linux distributions.
I have said before that I'm very willing to help to figure out any issues, regardless of which platform, and I stand by that statement -- if you see anything that is broken in this context and report the issue to me I'll jump on it immediately.
Quoted 5 lines
Quoted 4 lines
Nevertheless, there is currently this huge push, including breaking changes after -rc1 and all, for switching to Meson. Therefore, we need to make it work, somehow, even in Git for Windows' SDK, hence this patch, at this point in time.
Quoted 8 lines
As I said earlier already, I do not mind turning the type of this pointer, which is only used to read from a struct member, like this patch does. It is the right thing to do, so I'll apply.
But I personally would not be comfortable with the product built with "completely different tool version/compiler flags vector than what G4W needs", even the compilation passes with just this small change. If I were using Windows, that is.
That's completely fair. The CI job we have isn't meant to verify that we have a G4W-compatible distribution falling out of it, it merely verifies that we can build and pass tests in such a "standalone" (that is, without the SDK) configuration. We might eventually want to introduce another job that _does_ use the SDK with Meson, as well, but I didn't yet see a need for that until now.
Patrick
Re: [PATCH v2 1/3] ident: stop assuming that `gw_gecos` is writable
Quoted 7 lines · Patrick Steinhardt
I think it would be a bit sad to disable those jobs. They build and pass the test suite alright in Git itself, even though they fail downstream in Git for Windows. They help me quite a bit to ensure that I don't regress anything that already is working while I'm iterating on the current set of features. So in the end, I view them more as testing more variants of Windows than replacing what we currently have, similar to how we test Git on different Linux distributions.
Hmph, but compared to Linux or macOS platforms, do developers on Windows (and users of Git on Windows, including but not limited to users of Git-for-windows) benefit from having the code base to be tested on "more variants of Windows", or would it be more noise that they need to go visit the failing CI and spend time to triage if the breakage is something they should worry about?
The above is more or less a rhetorical question. I think by now everybody knows I do not like monoculture, and if we had infinite engineering resources, I would think it would be healthy to have more than one prominent and competing Windows port of Git (no, I know about Cygwin, but I hear that the platform is POSIXy enough, so I do not exactly consider Git running on Cygwin qualifies as "a Windows port"). But we do not seem to live in such a world.
Quoted 4 lines
I have said before that I'm very willing to help to figure out any issues, regardless of which platform, and I stand by that statement -- if you see anything that is broken in this context and report the issue to me I'll jump on it immediately.
It's ultimately up to Windows folks to take you up on the offer.
Quoted 11 lines
Quoted 5 lines
Quoted 4 lines
Nevertheless, there is currently this huge push, including breaking changes after -rc1 and all, for switching to Meson. Therefore, we need to make it work, somehow, even in Git for Windows' SDK, hence this patch, at this point in time.
...
That's completely fair. The CI job we have isn't meant to verify that we have a G4W-compatible distribution falling out of it, it merely verifies that we can build and pass tests in such a "standalone" (that is, without the SDK) configuration. We might eventually want to introduce another job that _does_ use the SDK with Meson, as well, but I didn't yet see a need for that until now.
Knowing that it is the most widely used platform, I naturally and naïvely was expecting and hoping that there are folks other than Dscho who have enough bandwidth and inclination to help in this area, but so far, having a set of jobs in CI that use a toolchain that is different from what G4W uses (as expected) did not quite help X-<. Nobody noticed it until the last minute.
Which made me say that we do not seem to live in such a world, which in turn makes me accept that putting all Windows eggs in a single basket and watch it closely may be a reasonable alternative when it comes to Windows [*], than hoping that diverse set of different builds eventually help flourishing Windows developer community.
I dunno.
[Footnote]
* Yes, I admit that it may be another way to say that I do not care the particular platform deeply enough.
PATCH v2 2/3 meson: fix sorting
In reply to Johannes Schindelin via GitGitGadgetFrom: Johannes Schindelin <[email protected]>
In 904339edbd80 (Introduce support for the Meson build system, 2024-12-06) the meson.build file was introduced, adding also a Windows-specific list of source files. This list was obviously meant to be sorted alphabetically, but there is one mistake. Let's fix that.
--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
@@ -1109,11 +1109,11 @@ elif host_machine.system() == 'windows' libgit_sources += [ 'compat/mingw.c', 'compat/winansi.c', + 'compat/win32/dirent.c', 'compat/win32/flush.c', 'compat/win32/path-utils.c', 'compat/win32/pthread.c', 'compat/win32/syslog.c', - 'compat/win32/dirent.c', 'compat/win32mmap.c', 'compat/nedmalloc/nedmalloc.c', ]
Signature · 1 line
gitgitgadget
PATCH v2 3/3 cmake: generalize the handling of the `CLAR_TEST_OBJS` list
In reply to Johannes Schindelin via GitGitGadgetFrom: Johannes Schindelin <[email protected]>
A late-comer to the v2.49.0 party, sk/unit-test-oid, added yet another array item to CLAR_TEST_OBJS, causing the win+VS build job to fail with symptoms like this one:
unit-tests-lib.lib(u-oid-array.obj) : error LNK2019: unresolved external symbol cl_parse_any_oid referenced in function fill_array
This is a similar scenario to the one that forced me to write 8afda42fce60 (cmake: generalize the handling of the UNIT_TEST_OBJS list, 2024-09-18): The hard-coded echo of CLAR_TEST_OBJS in CMakeLists.txt that recapitulates faithfully what was already hard-coded in Makefile would either have to be updated whack-a-mole style, or generalized.
Just like I chose the latter option for UNIT_TEST_OBJS, I now do the same for CLAR_TEST_OBJS.
--- contrib/buildsystems/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
contrib/buildsystems/CMakeLists.txt +8 -4
@@ -1001,10 +1001,14 @@ parse_makefile_for_sources(unit-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "UNIT_ list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/") add_library(unit-test-lib STATIC ${unit-test_SOURCES}) +parse_makefile_for_sources(clar-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "CLAR_TEST_OBJS") +list(TRANSFORM clar-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/") +add_library(clar-test-lib STATIC ${clar-test_SOURCES}) + parse_makefile_for_scripts(unit_test_PROGRAMS "UNIT_TEST_PROGRAMS" "") foreach(unit_test ${unit_test_PROGRAMS}) add_executable("${unit_test}" "${CMAKE_SOURCE_DIR}/t/unit-tests/${unit_test}.c") - target_link_libraries("${unit_test}" unit-test-lib common-main) + target_link_libraries("${unit_test}" unit-test-lib clar-test-lib common-main) set_target_properties("${unit_test}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin) if(MSVC)
@@ -1046,13 +1050,13 @@ add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" VERBATIM) add_library(unit-tests-lib ${clar_test_SUITES} - "${CMAKE_SOURCE_DIR}/t/unit-tests/clar/clar.c" "${CMAKE_BINARY_DIR}/t/unit-tests/clar-decls.h" "${CMAKE_BINARY_DIR}/t/unit-tests/clar.suite" ) +target_include_directories(clar-test-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests") target_include_directories(unit-tests-lib PUBLIC "${CMAKE_BINARY_DIR}/t/unit-tests") -add_executable(unit-tests "${CMAKE_SOURCE_DIR}/t/unit-tests/unit-test.c") -target_link_libraries(unit-tests unit-tests-lib common-main) +add_executable(unit-tests) +target_link_libraries(unit-tests unit-tests-lib clar-test-lib common-main) set_target_properties(unit-tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/t/unit-tests/bin) if(MSVC)
Signature · 1 line
gitgitgadget