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

Explicitly specify C++17 in libslic3r and libslic3r_cgal cmake, fixing build on Fedora 40 #4172

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

LightTreasure
Copy link
Contributor

@LightTreasure LightTreasure commented May 29, 2024

Bambu studio currently fails to build on Fedora 40. This is because the CMake configuration of libslic3r and libslic3r_cgal currently does not explicitly specify the C++ standard, but it seems like the libslic3r and libslic3r_cgal code assumes C++17. Without explicit specification, the compiler uses C++20.

Also added -Wno-error=template-id-cdtor to the compiler flags for Clipper2, preventing this warning from being thrown as an error. The template-id-cdtor warning being thrown as an error is a c++20 addition in gcc.

This fixes #4018.

…. Also excluded template-id-cdtor from Werror. These changes fix compilation issues on Fedora 40.
@lanewei120
Copy link
Collaborator

image
can not pass compile on old linux

@LightTreasure
Copy link
Contributor Author

image can not pass compile on old linux

Ah, this flag was introduced in a newer version of gcc. I wonder if there is a way to determine this in cmake...

@LightTreasure
Copy link
Contributor Author

I put the -Wno-error=template-id-cdtor flag behind a cmake if condition which should only apply if the compiler is gcc and the version is >=14.1 . This should fix the build.

@lanewei120
Copy link
Collaborator

some other errors found:
image
image

@LightTreasure
Copy link
Contributor Author

some other errors found: image image

Could you please point me to the full build log?

@lanewei120
Copy link
Collaborator

you can wait the compiling result from https://github.com/bambulab/BambuStudio/actions/runs/9296852419

@LightTreasure
Copy link
Contributor Author

@lanewei120 Looks like the build succeeded without errors.

@lanewei120
Copy link
Collaborator

compiling_error.txt
please find the attached file

@LightTreasure
Copy link
Contributor Author

@lanewei120 that is from the build before my second commit. It looks like the build after the second commit has no compilation errors and the binary was generated successfully.

Could you please try re-running the build to confirm?

@lanewei120
Copy link
Collaborator

the error is not found in clipper2
it is not related with your second commit

image

i already used all your commits for compiling

MackBambu added a commit to MackBambu/BambuStudio that referenced this pull request Jun 23, 2024
@MackBambu
Copy link
Contributor

@LightTreasure
Copy link
Contributor Author

LightTreasure commented Jun 24, 2024

https://github.com/MackBambu/BambuStudio/actions/runs/9635067680/job/26571467884 ubuntu 20.04 build failed

Investigating.

@LightTreasure
Copy link
Contributor Author

After some digging, I can see that this error is related to the following discussion: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40856

In summary, seems like the use of the type __int128 is not fully implemented when using -std=c++11. It requires the use of -std=gnu++11. However, using gnu++11 causes the issues I noted in #4018 in newer versions of g++, and this issue got fixed in the newer versions.

This is why the Ubuntu 24.04 build succeeded, but 20.04 failed.

I will put in the same gcc version check in src/libslic3r/CMakeLists.txt as I did in src/clipper2/CMakeLists.txt

@LightTreasure
Copy link
Contributor Author

LightTreasure commented Jun 25, 2024

@MackBambu I made a change that should make this work. Could you please re-run the build as you did before and check if it works?

MackBambu added a commit to MackBambu/BambuStudio that referenced this pull request Jun 25, 2024
@LightTreasure
Copy link
Contributor Author

@MackBambu Looks like the build succeeded! One thing to note is that the version check for gcc version 14.1 is somewhat arbitrary. I'm not sure which exact version of gcc will make my changes work. However, > 14.1 is a safe choice because that's the version I tested on Fedora 40.

@MackBambu
Copy link
Contributor

https://github.com/MackBambu/BambuStudio/actions/runs/9657794626
All three platforms are fine.
@lanewei120 Need to verify in Fedora 36?

@lanewei120
Copy link
Collaborator

https://github.com/MackBambu/BambuStudio/actions/runs/9657794626 All three platforms are fine. @lanewei120 Need to verify in Fedora 36?

yes, we will have a try

Copy link
Contributor

@MackBambu MackBambu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fedora 40, ubuntu 20, ubuntu 24 is ok
good job

@LightTreasure
Copy link
Contributor Author

Fedora 40, ubuntu 20, ubuntu 24 is ok good job

Thank you! This confirms that requiring gcc > 14.1 for the changes I made is a safe choice for
currently supported distros.

But it is important to note that the version number 14.1 is somewhat arbitrary - if a prior version of gcc results in compilation issues as described in the original bug ( #4018 ), then the version check needs to be update to that version.

@lanewei120 If you are okay with these changes, please review and I can submit this PR.

@lanewei120 lanewei120 merged commit e170819 into bambulab:master Jul 13, 2024
2 checks passed
@lanewei120
Copy link
Collaborator

thanks for doing this

@LightTreasure LightTreasure deleted the linux_build_c++17 branch July 15, 2024 17:59
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.

Building from source fails on Fedora 40
3 participants