Mercury Bugs - mercury
View Issue Details
0000288mercuryBugpublic2013-06-04 03:272013-06-24 11:12
Reporterkeri 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000288: Some mercury binary files are built without respecting LDFLAGS
DescriptionCompiling mercury (on Linux) with 'make EXTRA_LDFLAGS=...' produces a number of binary files which do not respect EXTRA_LDFLAGS:

 * /usr/lib/mercury/lib/libgc.so
 * /usr/lib/mercury/lib/<grade>/libmer_trace.so
 * /usr/lib/mercury/lib/<grade>/libmer_eventspec.so
 * /usr/lib/mercury/lib/<grade>/libmer_rt.so
 * /usr/bin/mfiltercc
 * /usr/bin/info_to_mdb
 * /usr/bin/mkinit_erl
 * /usr/bin/mdemangle
 * /usr/bin/mkinit
Additional InformationAttached is a patch which passes through ALL_LDFLAGS to targets that currently do not respect user-defined LDFLAGS.
TagsNo tags attached.
Attached Filespatch mercury-linker-flags.patch (5,206) 2013-06-04 03:27
https://bugs.mercurylang.org/file_download.php?file_id=175&type=bug
patch mercury-linker-flags-v2.patch (5,242) 2013-06-07 00:19
https://bugs.mercurylang.org/file_download.php?file_id=176&type=bug

Notes
(0000535)
juliensf   
2013-06-05 16:09   
EXTRA_LDFLAGS is an mmake variable not a make one; I wouldn't necessarily expect setting it for make would work.

Does it work if you pass the options in via the MMAKEFLAGS variable, for example:

   make MMAKEFLAGS="EXTRA_LDFLAGS='<whatever linker flags>'"
(0000537)
keri   
2013-06-07 00:20   
There are two issues at play with LDFLAGS/LD_LIBFLAGS and mmake:

1. some mercury binaries are built with respecting the LDFLAGS/LD_LIBFLAGS passed to mmake.

This is caused by some Mmakefile rules ommitting ALL_LDFLAGS/ALL_LD_LIBFLAGS from the linker options. I've uploaded a new mercury-linker-flags-v2.patch that adds:

* ALL_LDFLAGS to util/Mmakefile rules
* ALL_LD_LIBFLAGS to {runtime,trace}/Mmakefile rules
* LD_LIBFLAGS/EXTRA_LD_LIBFLAGS to boehm_gc Makefile. (ALL_LD_LIBFLAGS is not visible from make)

2. custom MMAKEFLAGS are not passed to mmake from the toplevel Makefile

The toplevel Makefile explicitly passes MMAKEFLAGS=$(PARALLEL) to mmake, overriding anything set via 'make MMAKEFLAGS="..."'. Patching the toplevel Makefile to use MMAKEFLAGS+=$(PARALLEL) is a possible fix.
(0000543)
juliensf   
2013-06-24 11:12   
Committed, along with some additions to support the same for .dylib files properly.

Issue History
2013-06-04 03:27keriNew Issue
2013-06-04 03:27keriFile Added: mercury-linker-flags.patch
2013-06-05 16:09juliensfNote Added: 0000535
2013-06-07 00:19keriFile Added: mercury-linker-flags-v2.patch
2013-06-07 00:20keriNote Added: 0000537
2013-06-20 18:02juliensfAssigned To => juliensf
2013-06-20 18:02juliensfStatusnew => assigned
2013-06-24 11:12juliensfNote Added: 0000543
2013-06-24 11:12juliensfStatusassigned => resolved
2013-06-24 11:12juliensfResolutionopen => fixed