Discussion:
Passing arguments into LDFLAGS
Paul F. Johnson
2010-09-22 12:08:11 UTC
Permalink
Hi,

I know I can do the likes of

export CFLAGS="$CFLAGS -blah" and it will pass whatever CFLAGS is plus
the argument "-blah" to the compiler.

How do I do this with LDFLAGS. I'm trying to pass --build-id using

export LDFLAGS="$LDFLAGS --build-id"

It's about the only way I can get mono to build currently!

TTFN

Paul
--
Vertraue mir, ich weiss, was ich mache...
Paul F. Johnson
2010-09-22 12:08:11 UTC
Permalink
Hi,

I know I can do the likes of

export CFLAGS="$CFLAGS -blah" and it will pass whatever CFLAGS is plus
the argument "-blah" to the compiler.

How do I do this with LDFLAGS. I'm trying to pass --build-id using

export LDFLAGS="$LDFLAGS --build-id"

It's about the only way I can get mono to build currently!

TTFN

Paul
--
Vertraue mir, ich weiss, was ich mache...
Ralf Corsepius
2010-09-22 12:30:06 UTC
Permalink
Post by Paul F. Johnson
Hi,
I know I can do the likes of
export CFLAGS="$CFLAGS -blah" and it will pass whatever CFLAGS is plus
the argument "-blah" to the compiler.
How do I do this with LDFLAGS.
Depends on a build-system's internals.
Post by Paul F. Johnson
I'm trying to pass --build-id using
export LDFLAGS="$LDFLAGS --build-id"
In many cases, this is _the way_ how to do it.

Another possibility would be to add linker flags to CFLAGS.
Something similar to -Wl,<flags to pass to the linker>, c.f. man gcc for
details.
Post by Paul F. Johnson
It's about the only way I can get mono to build currently!
... no clues about mono on my part.

... and I am not sure if --build-id is a linker option or a general GCC
option (This would mean it should be added to CFLAGS).

Ralf
Stephen Gallagher
2010-09-22 13:58:59 UTC
Permalink
Post by Paul F. Johnson
Hi,
I know I can do the likes of
export CFLAGS="$CFLAGS -blah" and it will pass whatever CFLAGS is plus
the argument "-blah" to the compiler.
How do I do this with LDFLAGS. I'm trying to pass --build-id using
export LDFLAGS="$LDFLAGS --build-id"
It's about the only way I can get mono to build currently!
TTFN
Paul
Try
export LDFLAGS="$LDFLAGS -Wl,--build-id"

- -Wl, means "pass the part after the comma directly to the linker"

- --
Stephen Gallagher
RHCE 804006346421761

Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
Garrett Holmstrom
2010-09-22 14:30:42 UTC
Permalink
Post by Stephen Gallagher
Post by Paul F. Johnson
I know I can do the likes of
export CFLAGS="$CFLAGS -blah" and it will pass whatever CFLAGS is plus
the argument "-blah" to the compiler.
How do I do this with LDFLAGS. I'm trying to pass --build-id using
export LDFLAGS="$LDFLAGS --build-id"
It's about the only way I can get mono to build currently!
TTFN
Paul
Try
export LDFLAGS="$LDFLAGS -Wl,--build-id"
- -Wl, means "pass the part after the comma directly to the linker"
This. When gcc is used to indirectly call ld, it won't always pass the
$LDFLAGS to the linker. To force it to you have to use the -Wl switch
and replace all spaces in the switch with commas. For example:

LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl--build-id -s"
Roland McGrath
2010-09-23 20:33:16 UTC
Permalink
As I said before, this is almost certainly the wrong fix. If you share
your code already, you will get the help you need quickly. As long as you
don't, and just ask over-specific questions rather than let people see the
context to help you properly, you will get only frustration.


Thanks,
Roland

Loading...