Open kepstin opened 2 years ago
I hate to be the one that says "it looks like a toolchain bug" but it looks like a toolchain bug? dynamic_cast is supposed to provide a safe way to either cast a pointer from one type to another, or return NULL. Crashing is neither of those two options.
bees doesn't actually use derived types of Fd, so the main bees binary should still work.
LTO with gcc 11+ is really problematic... If you compile the toolchain itself with lto, it will make libstdc++ completely unusable because most stdlib symbols are missing for linking.
I've tried g++-11 (Debian 11.2.0-12) 11.2.0
and g++ (GCC) 11.2.1 20211203 (Red Hat 11.2.1-7)
with no problems so far. Which distro is having problems?
The particular distro I'm seeing this issue on is Exherbo which is admittedly a pretty niche distribution. FWIW, the core toolchain stuff (GCC itself) is built without LTO.
At the moment I'm inclined to agree that this is a toolchain bug, indeed.
Which distro is having problems?
Gentoo here... The problem is compiling gcc itself with -flto
- it breaks the symbol visibility. Some other libraries may be affected, too. I've only encounted C++ stdlib so far. This is a known issue. Currently, I stopped using -flto
for essential core libraries like gcc (which provides libstdc++), glibc and a few others.
Actually, Gentoo is aware of the issue but they lately added a feature compiling gcc with custom cflags, and that accidentally broke my system, and it was really difficult to escape that problem. As an example, cmake would no longer run, and it won't compile, and many packages depend on it. boost was broken, too. I probably would also have encountered bees as a problem but that just isn't an essential package so I didn't notice it.
Compiling just leaf packages of the dependency tree with LTO is usually no problem at all because it doesn't export symbols used by other libraries.
Using -fvisibility-inlines-hidden
causes the same problem currently when compiling gcc-11 itself (read: not compile WITH gcc-11, but bootstrap gcc itself).
So in the end the problem here may be that other software has been compiled with LTO, and thus bees won't compile, probably no matter if with or without LTO. Compiling gcc itself with LTO seems completely broken, and compiling some libraries with gcc-11 and LTO seems to be broken, too.
While doing some testing in preparation for packaging bees, I did a build using
make CXXFLAGS=-flto CFLAGS=-flto
to verify that the build would work correctly with gcc LTO.Using GCC version 11.2.0.
I'm seeing the following test failure in
fd
:Here's a backtrace from the error:
I… don't know enough about C++ to know exactly what this means, but there's apparently some change in how exception handling works with gcc LTO in this compiler version. From other folks testing on IRC it seems like this might be specific to the gcc version I'm using.