Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2023-08

LLVM LTO

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Benito van der Zander

Hallo,

I tried to use the LLVM Link-Time-Optimization, -Clflto

I compiled/installed fpc llvm with a separate prefix, which was already difficult to set up

Then the default linker did not want to link it.

The wiki says to use the gold linker. I do not know how to change the linker in fpc.cfg. If I use -XP, it changes the prefix. But the gold linker is named ld.gold, so one would need an option to change the suffix.

But I called it directly with ld.gold -T link43117.res.

It says

ld.gold: error: link43117.res:372:8: syntax error, unexpected STRING

I deleted the last line INSERT AFTER .data;. Then it says

ld.gold: internal error in read_script_file, at ../../gold/script.cc:1638

around here:
https://sourceware.org/git/?p=binutils-gdb.git;a=blame;f=gold/script.cc;h=d30a4d73991f083f3a1459db06ded4234959fe91;hb=HEAD#l1638

So I gave up on that and tried the llvm linker. ld.lld -T link43117.res

It links, but when I start the program, it gives

Starting program: /home/benito/tmp/a.out

Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000in ??()
(gdb) bt
#0 0x0000000000000000in ??()
#1 0x0000000000000000in ??()

Viele Grüße,

Benito

Reply by email

Jonas Maebe
to Benito van der Zander
Benito van der Zander wrote
I tried to use the LLVM Link-Time-Optimization, -Clflto

I should update the wiki page. Under Debian 11, I can tell FPC to use gold with lto by specifying the following command line parameters: -Clflto -Clflto-no-system -k-fuse-ld=gold -k-plugin=/path/to/LLVMgold.so

Note that compiling the FPC RTL with LTO currently doesn't work under Linux, because LLVM does not rename local labels in pure assembler procedures when doing so, resulting in duplicate labels.

It works fine when compiling FPC and its units normally, and then only using LTO for your program.

Jonas

Reply by email

Benito van der Zander
to Jonas Maebe

Hi

-Clflto -Clflto-no-system -k-fuse-ld=gold -k-plugin=/path/to/LLVMgold.so

that helped, but I have to do it without -Clflto-no-system, or it gives an error

Then I could run my unit tests:

FPC alone: 25 seconds
LLVM: 21 seconds
LLVM LTO: 20 seconds

does not seem to matter much

Cheers,
Benito

Jonas Maebe wrote 19 lines
On 10/08/2023 17:06, Benito van der Zander via fpc-pascal wrote: > I tried to use the LLVM Link-Time-Optimization, -Clflto I should update the wiki page. Under Debian 11, I can tell FPC to use gold with lto by specifying the following command line parameters: -Clflto -Clflto-no-system -k-fuse-ld=gold -k-plugin=/path/to/LLVMgold.so Note that compiling the FPC RTL with LTO currently doesn't work under Linux, because LLVM does not rename local labels in pure assembler procedures when doing so, resulting in duplicate labels. It works fine when compiling FPC and its units normally, and then only using LTO for your program. Jonas _______________________________________________ fpc-pascal maillist  - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Jonas Maebe
to Benito van der Zander
Benito van der Zander wrote 6 lines
Hi > -Clflto -Clflto-no-system -k-fuse-ld=gold -k-plugin=/path/to/LLVMgold.so that helped, but I have to do it without -Clflto-no-system, or it gives an error

That was a typo, it's -Clfltonosystem. But it doesn't matter if the RTL is not compiled with LTO.

Show quoted text 7 lines
Then I could run my unit tests: FPC alone: 25 seconds LLVM: 21 seconds LLVM LTO: 20 seconds does not seem to matter much

It depends on the program.

Jonas

Reply by email