btdu icon indicating copy to clipboard operation
btdu copied to clipboard

GCC bug with btdu

Open Forza-tng opened this issue 1 year ago • 6 comments

I tried to use gdc (gcc d compiler), however it failed. It seems to be a bug in gcc(*). I was able to compile btdu with LLVM's ldc, which worked good.

To use another compiler than dmd, I used rhe following:

dub build --compiler=ldc2 -b release

It is interesting that ldc2 made a much smaller binary.

-rwxr-xr-x 1 forza forza  19M Aug 15 23:17 btdu.dmd*
-rwxr-xr-x 2 forza forza 4,2M Sep 30 23:15 btdu.ldc2*
-rwxr-xr-x 2 forza forza 5,7M Sep 30 23:33 btdu.ldc2.O3-lto*

(*) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111650

Forza-tng avatar Oct 03 '23 09:10 Forza-tng

Thanks!

BTW, the likely reason why the LDC-produced binaries are smaller is that, by default and unlike DMD, it links to the runtime and standard library dynamically.

CyberShadow avatar Oct 03 '23 09:10 CyberShadow

That makes sense. I couldn’t make a static version eith ldc2. I suspect that I also need static versions of the library. It's of course not a problem as I compile for my own system.

 DFLAGS="-O3 --flto=full --static" dub build --compiler=ldc2 --combined -f -b release
    Starting Performing "release" build using ldc2 for x86_64.
    Building btdu 0.5.1+commit.100.g76b07f9: building configuration [application]
     Linking btdu
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lncursesw: No such file or directory
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -ltinfow: No such file or directory
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lphobos2-ldc: No such file or directory
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -ldruntime-ldc: No such file or directory
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
Error ldc2 failed with exit code 1.

Forza-tng avatar Oct 03 '23 10:10 Forza-tng

Yes. Note that the CI builds static/LTO versions of everything. You can request to just link the static standard library / runtime with -link-defaultlib-shared=false.

CyberShadow avatar Oct 03 '23 10:10 CyberShadow