-
Notifications
You must be signed in to change notification settings - Fork 492
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 build linkage error #37
Comments
I'll double-check what I get on Linux, but this seems like a compiler bug as the compiler is told to default-generate |
That is very puzzling. Agreed with @pierremoreau. I'm also surprised that it happens in just those two files; I would imagine that default constructor is used in many more files, so if there was a weird failure / compiler issue, I'd expect it to be more widespread. If you do a make clean and then rebuild, does it still happen? |
@mmp I am sorry but yes; I tried multiple times from scratch (removing the build directory and creating a new one), even restricting the compilation to a unique thread and it always produces the same error, but even earlier:
|
It could be that only the first 20 or so undefined references were returned and not all of them, so it could potentially be more widespread than reported. I tried compiling the latest master with GCC 10.2.0 on Linux without any issues; I did use Ninja rather than make so I’ll try again tomorrow with make and see if I get different results. @webanck Are you able to try a more recent version of GCC, or using clang instead? |
...this might be a g++ bug. Here is an old bug report that fits the symptoms. It's not marked fixed yet, but it's pretty old... Could you try changing the line |
@pierremoreau I don't have sudoers rights on the environment; that's the problem. So to try with a more recent version of gcc, I would have to compile it from source. |
Maybe you could force the compiler to instantiate the constructors by adding the following to util/pstd.cpp: pstd::optional<pbrt::Bounds2<int>> _unused1;
pstd::optional<pbrt::Point2<int>> _unused2;
pstd::optional<pbrt::RGBColorSpace const*> _unused3;
pstd::optional<int> _unused4;
pstd::optional<float> _unused5;
That's indeed a problem… no clang already installed I guess otherwise you would have tried it.
It must have been fixed at some point since I did not ran in it with GCC 10.2.0. |
Not all the required types such as
My suspected culprit is the line using the
Exactly. |
I just tried to compile in Debug mode, and it worked like a charm! |
The optimisation level is different between the two; you could try -Og or -O0 in Release mode and see if you still hit the same issue. |
After further tests, it appears to compile and link successfully only with the By the way, adding |
Ah, good find!
Yes, CMake adds |
So as far as a fix (or "workaround", I suppose), pbrt's CMakeLists.txt file should add |
Attempt to workaround gcc bug. Issue #37.
I've just (finally) pushed a fix that should in theory add that flag with versions of gcc before 8.0. If you have a chance to try it out and see if it builds out of the box on that system at some point, that'd be fantastic. |
Flagging that the change in 95b4c9b is now breaking with gcc 7.4.
I was able to build pbrt-v4 up until this change without any issue. This appears to have exposed another compiler bug that was fixed in gcc 7.5 I suspect, but haven't tested/verified, that the original issue is limited to just gcc 7.2, 7.3 and 8.0. Edit, now that I've tested with gcc 7.3 |
I just tried to compile on the IN2P3 environment, and I am getting the same kind of error as @shadeops:
|
I should add that my current modified version of the CMakeFiles.txt works but is configured for static build:
|
Came across this while Googling which appears to be the same issue with possible workaround - |
Ack--sorry. I've reverted that, then. @webanck are those the only changes you need to build with gcc 7.3.0, or is it that plus
to
in util/pstd.h and seeing if it builds with the top-of-tree CMakeLists.txt? |
@mmp The complete set of necessary options to compile in the environment of the IN2P3 was:
Sadly, following your advice with |
Attempt to workaround gcc bug. Issue mmp#37.
Trying to compile on the IN2P3 environment with
cmake-3.18.2
compiled from source, I get linkage errors:How to pass the linkage successfully ?
For more details, below is the cmake output:
The text was updated successfully, but these errors were encountered: