Fix module build#137
Conversation
|
There seem to be some failing checks so I am turning this into a draft until I find out what is going on. |
|
OK, I found the problem with MSVC. I don't want to fix it with a quick hack, so I'll provide a proper fix later today. Until then I am leaving the PR as a draft. |
fe15b62 to
df3a4b5
Compare
|
OK, it should be ready for a review now. |
rbock
left a comment
There was a problem hiding this comment.
Successfully tested with gcc-15.2.0 and cmake-3.31.6
I left a couple of comments and questions.
82578e7 to
b5f89e1
Compare
Do you mean that you tested the old code (before this PR) with gcc-15.2.0 and cmake-3.31.6 and it compiled successfully with modules? Or do you mean that you tested the new code (with this PR) with gcc-15.2.0 and cmake-3.31.6 and it compiled successfully with modules? |
This :-) |
OK, thanks for the clarification. I am somewhat convinced that the reason for the problem is that gcc started emitting those |
b5f89e1 to
3d93139
Compare
…ERFACE libraries for our module targets.
…arget include path, because we don't actually use it as an include directory.
3d93139 to
a44c939
Compare
|
This looks good to me at this point. Happy to merge if you agree. |
I do agree. Let's merge the current PR and its code is an improvement over the current state (it fixes one build bug and removes some code duplication). Then we can improve the code further in other PR(s). |
|
Thanks for the fix, cleanup, and discussion! |
This PR fixes a bug which prevented building any of the test code with modules enabled. The bug manifested on my machine with the following setup
and the following build commands:
caused the following build error:
After some investigation it turned out that the culprit is the use of
INTERFACEtargets for the various tests (e.g. sqlpp23_core_testing). The interface targets don't propagate the compiled.ofiles owned by theOBJECTtargets they depend on. Instead theINTERFACEtargets silently drop the.ofiles without using them. As a result the initialization code for modulesqlpp23.mock_db, which is inside the .o files, is silently dropped and the linker complains when it tries to use it.I don't know why the code worked fine until now and I only saw this bug now. I am pretty sure that building sqlpp23 with modules and testing worked fine for me until now, when it just stopped working :-)
I suspect I think that this bug existed before, but we just haven't come across it now.
My prime suspect is the new GCC 16.1.1. I think that the previous versions of GCC were optimizing happily the
static constexprvars insqlpp23/include/sqlpp23/core/debug_logger.h
Line 40 in e4f47a8
and
sqlpp23/include/sqlpp23/core/database/transaction.h
Line 33 in e4f47a8
but the new GCC actually emits those constants into the
.textsection of the object files and actually generates some static initializer code that should be called on startup, so the modulesqlpp23.mock_dbnow needs to be initialized at runtime. Previously dropping the .o files was OK, because there was no initialization function in them, so no linker errors were caused.But all that is just an educated guess, because I don't have the old GCC and CMake, so I cannot check what code they were generating in the past.
Anyway, this PR fixes the problem by changing the test library target from OBJECT to the default static/dynamic type. The PR also cleans up a bit the CMake code that generates the test targets. I think there are more cleanups of the CMake test code that could (and probably should) be done, but I guess this can wait until I get the time and inspiration (or until someone else does :-)
EDIT: I built and tested this PR with both
and