Raised This Month: $18 Target: $400
 4% 

Cannot enable LTO when linking against pcre


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FlanZarianick
New Member
Join Date: Jun 2022
Old 09-29-2022 , 03:03   Cannot enable LTO when linking against pcre
Reply With Quote #1

I'm contributing to one open-source project named AMX Mod X. It uses really simple, custom-made build system (called AMBuild). Project is built using Clang on Linux.

I tried to enable LTO for it, just by passing compile-time and link-time arguments.

As a link time arguments I added

-O2 -flto=thin -fuse-ld=lld -Wl,-z,notext
And as a compile-time arguments.

-O2 -flto=thin -fPIC
I selected this configuration after careful googling. It seems I'm very close to achieving complete LTO. Only one module fails to build, it links against pcre.

Generated (by build system) linking command is like this.

clang-4.0 _public_sdk_amxxmodule.o module.o CRegEx.o utils.o -m32 -O2 -flto=thin -fuse-ld=lld -Wl,-z,notext -ldl -lm -lgcc_eh ../../../support/versionlib/version/libversion.a /home/travis/build/alliedmodders/amxmodx/modules/regex/lib_linux/libpcre.a -shared -o regex_amxx_i386.so
And linking errors are many, but they are very similar. This is one of them.

/usr/lib/llvm-4.0/bin/ld.lld: error: pcre_compile.cfunction add_to_class): can't create dynamic relocation R_386_32 against symbol '_pcre_ucd_stage1' defined in /home/travis/build/alliedmodders/amxmodx/modules/regex/lib_linux/libpcre.a(libpcre_la-pcre_ucd.o)
I read that LLD and bfd have different defaults and -Wl,-z,notext should work, but it didn't have any effect.

libpcre.a is just a binary file bundled with repository. AMBuild isn't building pcre from sources. This is my PR, you can find there failed travis build and read logs more carefully. Don't be afraid against custom build system, all executed commands are printed to the terminal in the most verbose form. It shouldn't be problem.

How to enable LTO when linking against pcre? I don't really care about other compilers (gcc, icc, etc..) or other operating systems.
FlanZarianick is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:09.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode