Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

LDFLAGS Central

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
51 posts
  • Previous
  • 1
  • 2
  • 3
  • Next
Author
Message
Hasw
n00b
n00b
Posts: 68
Joined: Fri Dec 31, 2004 12:25 am
Location: Germany
Contact:
Contact Hasw
Website

  • Quote

Post by Hasw » Tue May 31, 2005 11:25 pm

Hm, I'm getting a Segmentation fault:

Code: Select all

hasw@hasw hasw $ LD_DEBUG=statistics sh -c true
     26096:     
     26096:     runtime linker statistics:
     26096:       total startup time in dynamic loader: 595306 clock cycles
     26096:                 time needed for relocation: 289777 clock cycles (48.6%)
Segmentation fault
hasw@hasw hasw $ 
sys-devel/binutils 2.15.92.0.2-r7
sys-libs/glibc 2.3.4.20041102-r1
Top
Bitspyer
Apprentice
Apprentice
User avatar
Posts: 211
Joined: Tue Dec 17, 2002 10:49 am
Location: Mainz, Germany

  • Quote

Post by Bitspyer » Wed Jun 01, 2005 9:33 am

Hmmm I'm asking me, what is the better solution:

LDFLAG or prelink? Or both together???
Der Weg zur Dunklen Seite... Schneller er ist, verführerischer, leichter.
Top
Dark_Cloud
n00b
n00b
User avatar
Posts: 27
Joined: Sun Jun 29, 2003 1:40 pm

  • Quote

Post by Dark_Cloud » Wed Jun 01, 2005 4:45 pm

Bitspyer wrote:Hmmm I'm asking me, what is the better solution:

LDFLAG or prelink? Or both together???
you can use both.:D
Top
yardbird
l33t
l33t
User avatar
Posts: 689
Joined: Sat Apr 20, 2002 7:02 pm
Location: nl.leiden

  • Quote

Post by yardbird » Fri Jun 03, 2005 1:40 am

Hasw wrote:Hm, I'm getting a Segmentation fault:

Code: Select all

hasw@hasw hasw $ LD_DEBUG=statistics sh -c true
     26096:     
     26096:     runtime linker statistics:
     26096:       total startup time in dynamic loader: 595306 clock cycles
     26096:                 time needed for relocation: 289777 clock cycles (48.6%)
Segmentation fault
hasw@hasw hasw $ 
Same here... do you have custom LDFLAGS set in make.conf?
Albert Einstein wrote:I consider it [...] urgently necessary for [...] workers to get together, both to protect their own economic status and [...] to secure their influence in the political field.
http://www.bluescarni.info
Top
teutzz
Guru
Guru
User avatar
Posts: 333
Joined: Thu Apr 22, 2004 5:26 pm
Location: .ro
Contact:
Contact teutzz
Website

  • Quote

Post by teutzz » Fri Jun 03, 2005 7:11 am

Code: Select all

Teutzz teutzz # LD_DEBUG=statistics sh -c true
     17293:
     17293:     runtime linker statistics:
     17293:       total startup time in dynamic loader: 411310 clock cycles
     17293:                 time needed for relocation: 14399 clock cycles (3.5%)
     17293:                      number of relocations: 0
     17293:           number of relocations from cache: 21
     17293:             number of relative relocations: 0
     17293:                time needed to load objects: 236055 clock cycles (57.3%)
     17293:
     17293:     runtime linker statistics:
     17293:                final number of relocations: 65
     17293:     final number of relocations from cache: 21
and in my make.conf:

Code: Select all

Teutzz teutzz # cat /etc/make.conf | grep LDFLAGS
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s -Wl,--as-needed"
and the whole system is prelinked
Cand nu stii ce sa raspunzi sau ce sa spui un simplu BLA ajunge... lolz
Top
yardbird
l33t
l33t
User avatar
Posts: 689
Joined: Sat Apr 20, 2002 7:02 pm
Location: nl.leiden

  • Quote

Post by yardbird » Fri Jun 03, 2005 11:19 am

Hmm, I tried upgrading to binutils 2.16 but still the segfault... It's strange since I never had problems with binutils, I'd probably would have never discovered the issue if I had not seen this thread.

@Teutzz: I'm using your same LDFLAGS (apart from -as-needed), so I guess the problem is not there. Does anyone know what commands are executed when executing the LD_DEBUG="..." command?

:?
Albert Einstein wrote:I consider it [...] urgently necessary for [...] workers to get together, both to protect their own economic status and [...] to secure their influence in the political field.
http://www.bluescarni.info
Top
j-m
Retired Dev
Retired Dev
Posts: 975
Joined: Sun Oct 31, 2004 3:54 pm

  • Quote

Post by j-m » Thu Jun 09, 2005 9:03 am

Kyrra wrote:I had the same problem with using LDFLAGS to compile Emacs as listed in a post higher in this thread. But everything else I've compiled on my system hasn't had a problem with the LDFLAGS yet.
For emacs, you need only:

Code: Select all

LDFLAGS="-O1"
Probably the only package that does not interpret -Wl as an option passed to the linker.
Top
wel
Apprentice
Apprentice
Posts: 207
Joined: Wed Sep 03, 2003 9:31 pm

  • Quote

Post by wel » Fri Jun 10, 2005 10:46 pm

Anyone has tried something bigger than -O1? I mean, -O2 or -Os...
Top
taipan67
l33t
l33t
User avatar
Posts: 866
Joined: Sat Dec 04, 2004 10:04 am
Location: England (i'm told...)

  • Quote

Post by taipan67 » Sat Jun 11, 2005 7:09 pm

wel wrote:Anyone has tried something bigger than -O1? I mean, -O2 or -Os...
As i understand other people's posts on the subject, & the 'ld' man-page, the -O optimisation-flag has only two states: zero or not-zero. So setting it to 1, 2, 3, or whatever won't make a blind bit of difference, as long as it's a number greater than zero. It's not the same principle as CFLAGS, so there won't be a size-option, either.
"Anyone who goes to see a psychiatrist should have their head examined!"
Top
Zentoo
Apprentice
Apprentice
User avatar
Posts: 224
Joined: Mon Nov 18, 2002 5:53 pm
Location: /dev/console

Notice if u use specific LDFLAGS

  • Quote

Post by Zentoo » Wed Jun 15, 2005 12:52 pm

I've read this thread and i give you back my experience to have play a lot with my LDFLAGS this last year:

I've recompiled a whole system with this: LDFLAGS="-Wl,-O1"
At the first glaze no problem at all... But on the next reboot, system didn't finish to boot up.
It was looking for some libs on some partition that weren't yet mounted at boot.
It seems where is some problem with some library that are on /usr/*/lib and not on /lib that are required at boot.
It was enough a long time ago but i remember to have copy some library on /usr/*/lib without have mounted /usr
so no problem at boot time to look for them but i think it's a dirty hack...

So just be warned if you have a full separated partition scheme as i have about the use of LDFLAGS on a whole system.


Think about gpm libraries for reiserfs binaries was one of theses problems. ( i never understood the need of gpm for reiserfs !)
Top
j-m
Retired Dev
Retired Dev
Posts: 975
Joined: Sun Oct 31, 2004 3:54 pm

Re: Notice if u use specific LDFLAGS

  • Quote

Post by j-m » Wed Jun 15, 2005 2:23 pm

Tuttle wrote: At the first glaze no problem at all... But on the next reboot, system didn't finish to boot up.
It was looking for some libs on some partition that weren't yet mounted at boot.
It seems where is some problem with some library that are on /usr/*/lib and not on /lib that are required at boot.
WTF?! How does the location where libraries are installed in the system depend on LDFLAGS :?: :roll:
Top
MaratIK
n00b
n00b
User avatar
Posts: 20
Joined: Wed Apr 02, 2003 4:23 pm
Location: Moscow, Russia

--relax will not work on some packages

  • Quote

Post by MaratIK » Fri Feb 24, 2006 3:45 am

ld flag --relax conficts with -r, so they cannot use both.
Package where it occured is glibc-2.3.5.
It is strongly not recommended include -Wl,--relax into LDFLAGS
Top
MaratIK
n00b
n00b
User avatar
Posts: 20
Joined: Wed Apr 02, 2003 4:23 pm
Location: Moscow, Russia

  • Quote

Post by MaratIK » Fri Feb 24, 2006 3:59 am

schrepfler wrote:Are there any new tips for the use of LDFLAGS, what are some good configs for the 3.4, 3.4 and 4.0 compilers?
ld is not the part of gcc, but binutils. Tips the same as is for previous versions of gcc.
Top
MaratIK
n00b
n00b
User avatar
Posts: 20
Joined: Wed Apr 02, 2003 4:23 pm
Location: Moscow, Russia

  • Quote

Post by MaratIK » Mon Aug 28, 2006 4:02 pm

My settings for LDFLAGS:

Code: Select all

LDFLAGS="-Wl,-O1,--sort-common,--enable-new-dtags,-zdynsort,-Bdirect,-hashvals"
Some explanation of last 3 settings can be found here
Top
vipernicus
Veteran
Veteran
User avatar
Posts: 1462
Joined: Mon Jan 17, 2005 10:35 pm
Location: Your College IT Dept.
Contact:
Contact vipernicus
Website

Re: LDFLAGS Central

  • Quote

Post by vipernicus » Mon Sep 25, 2006 9:27 pm

taviso wrote:[*]--sort-common
This is to prevent gaps between symbols due to alignment constraints, presumably increasing efficiency layout.
Actually, it seems that it is the other way around.

-sort-common
Normally, when ld places the global common symbols
in the appropriate output sections, it sorts them
by size. First come all the one byte symbols, then
all the two bytes, then all the four bytes, and
then everything else. This is to prevent gaps be-
tween symbols due to alignment constraints. This
option disables that sorting.
Viper-Sources Maintainer || nesl247 Projects || vipernicus.org blog
Top
luminoso
n00b
n00b
User avatar
Posts: 60
Joined: Thu Oct 13, 2005 8:36 pm
Location: Portugal, Aveiro

  • Quote

Post by luminoso » Thu Oct 05, 2006 12:08 pm

Code: Select all

$ LD_DEBUG=statistics sh -c true
     28385:
     28385:     runtime linker statistics:
     28385:       total startup time in dynamic loader: 1578708 clock cycles
     28385:                 time needed for relocation: 29708 clock cycles (1.8%)
     28385:                      number of relocations: 0
     28385:           number of relocations from cache: 29
     28385:             number of relative relocations: 0
     28385:                time needed to load objects: 1107048 clock cycles (70.1%)
     28385:
     28385:     runtime linker statistics:
     28385:                final number of relocations: 0
     28385:     final number of relocations from cache: 29

Code: Select all

grep LDFL /etc/make.conf
LDFLAGS="-Wl,-O1"
And no problems at all.
What should i care? time needed to load or time needed for relocation?
Top
Enlight
Advocate
Advocate
User avatar
Posts: 3519
Joined: Thu Oct 28, 2004 9:42 am
Location: Alsace (France)

Re: LDFLAGS Central

  • Quote

Post by Enlight » Sun Nov 26, 2006 3:24 am

vipernicus wrote:
taviso wrote:[*]--sort-common
This is to prevent gaps between symbols due to alignment constraints, presumably increasing efficiency layout.
Actually, it seems that it is the other way around.

-sort-common
Normally, when ld places the global common symbols
in the appropriate output sections, it sorts them
by size. First come all the one byte symbols, then
all the two bytes, then all the four bytes, and
then everything else. This is to prevent gaps be-
tween symbols due to alignment constraints. This
option disables that sorting.
erm... no!
man binutils-2.17.50.0.6 wrote:--sort-common
This option tells ld to sort the common symbols by size when it
places them in the appropriate output sections
other than this, /me still wonders why --enable-new-dtags has been removed from the original post.

edit : @zentoo, definitly not, you probably were using a statical prog and forgot about this.
Top
Dralnu
Veteran
Veteran
User avatar
Posts: 1919
Joined: Wed May 24, 2006 5:33 pm

  • Quote

Post by Dralnu » Sat Mar 03, 2007 8:04 pm

Has anyone else messed with LDFLAGS in awhile? I'm going through and sorting out what might be nice and what might not be, and just want to know if there is any new news.



Edit: Um, have LDFLAGS been removed for some odd reason?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Top
wrc1944
Advocate
Advocate
Posts: 3467
Joined: Thu Aug 15, 2002 10:33 am
Location: Gainesville, Florida

  • Quote

Post by wrc1944 » Sat Mar 03, 2007 11:10 pm

Mine are currently

Code: Select all

LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=both -Wl,-znow"
on several boxes.

I've been using these with the advanced Gentoo install method and overlay by nesl247 (previously know as Evolution Mission). Works great for me, and the the few packages that have problems with --as-needed or -znow can be taken care of by entries in an /etc/portage/bashrc.nesl247 file, as shown below.
---------------------------------------------------------------------------------------------------
# Packages in this array remove --as-needed.
as_needed_packages=(
${as_needed_packages[*]}
media-video/mjpegtools
kde-base/kdemultimedia
kde-base/kdemultimedia-kioslaves
net-mail/courier-imap
media-sound/cdparanoia
mail-client/evolution
media-libs/imlib
)

LDFLAGS="${LDFLAGS:-$( grep ^LDFLAGS /etc/make.conf | sed 's/LDFLAGS="//' | sed 's/"//')}"

for i in ${as_needed_packages[*]}
do
case ${CATEGORY}/${PN} in
${i})
LDFLAGS="$( echo ${LDFLAGS} | sed 's/-Wl,--as-needed//')"
break
;;
esac
done

# Packages in this array remove -znow.
znow_packages=(
${znow_packages[*]}
dev-python/gst-python
x11-base/xorg-server
x11-drivers/ati-drivers
)

for i in ${znow_packages[*]}
do
case ${CATEGORY}/${PN} in
${i})
LDFLAGS="$( echo ${LDFLAGS} | sed 's/-Wl,-znow//')"
break
;;
esac
done

export LDFLAGS=$( echo ${LDFLAGS} )
Main box- AsRock x370 Gaming K4
Ryzen 7 3700x, 3.6GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
OpenRC Gentoo ~amd64 plasma, glibc-2.41-r2, gcc-15.1.0
kernel-6.15.6 USE=experimental python3.13.3
Top
Dralnu
Veteran
Veteran
User avatar
Posts: 1919
Joined: Wed May 24, 2006 5:33 pm

  • Quote

Post by Dralnu » Sun Mar 04, 2007 12:37 am

Ran into a problem. its -W, not 1, but a lower case L.
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Top
wrc1944
Advocate
Advocate
Posts: 3467
Joined: Thu Aug 15, 2002 10:33 am
Location: Gainesville, Florida

  • Quote

Post by wrc1944 » Sun Mar 04, 2007 2:38 am

Correct. When you copy it from /etc/make.conf and paste it into the forum and add the code tags, the numeral one (1) and a lower case L really look almost identical. You have to look really close to see the numeral one has its top part at a slight downward angle, whereas the lower case L is horizontal.
Main box- AsRock x370 Gaming K4
Ryzen 7 3700x, 3.6GHz, 16GB GSkill Flare DDR4 3200mhz
Samsung SATA 1000GB, Radeon HD R7 350 2GB DDR5
OpenRC Gentoo ~amd64 plasma, glibc-2.41-r2, gcc-15.1.0
kernel-6.15.6 USE=experimental python3.13.3
Top
webdawg
n00b
n00b
Posts: 34
Joined: Wed Jul 26, 2006 4:33 pm

I had some ldflags that broke gst plugins. had to comment t

  • Quote

Post by webdawg » Tue Jun 12, 2007 3:58 am

I had some ldflags that broke gst plugins. had to comment them out.
Top
ConiKost
Developer
Developer
User avatar
Posts: 1371
Joined: Tue Jan 11, 2005 5:24 pm

  • Quote

Post by ConiKost » Thu Jun 21, 2007 8:52 pm

I am using atm this:

Code: Select all

LDFLAGS="-Wl,-O1 -Wl,-z,now -Wl,--as-needed -Wl,--enable-new-dtags -Wl,--sort-common -s"
works fine for me.
Top
enderandrew
l33t
l33t
User avatar
Posts: 731
Joined: Tue Oct 25, 2005 8:37 am

  • Quote

Post by enderandrew » Thu Jun 28, 2007 4:05 am

ConiKost wrote:I am using atm this:

Code: Select all

LDFLAGS="-Wl,-O1 -Wl,-z,now -Wl,--as-needed -Wl,--enable-new-dtags -Wl,--sort-common -s"
works fine for me.
Don't forget --hash-style=both

And I'm working on a toolchain overlay that will add back in support for -Bdirect among many other things!
Nihilism makes me smile.
Top
gimpel
Advocate
Advocate
User avatar
Posts: 2720
Joined: Fri Oct 15, 2004 10:08 am
Location: Munich, Bavaria
Contact:
Contact gimpel
Website

  • Quote

Post by gimpel » Thu Jun 28, 2007 7:40 am

Code: Select all

LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--sort-common"
on binutils-2.17.50.0.10 here.

No problems.
http://proaudio.tuxfamily.org/wiki - pro-audio software overlay
Top
Post Reply

51 posts
  • Previous
  • 1
  • 2
  • 3
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic