2019-06-26 07:55 AEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000288mercuryBugpublic2013-06-24 11:12
Reporterkeri 
Assigned Tojuliensf 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
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 Files
  • patch file icon mercury-linker-flags.patch (5,206 bytes) 2013-06-04 03:27 -
    diff --git a/boehm_gc/Makefile.direct b/boehm_gc/Makefile.direct
    index 373bf84..ca1074c 100644
    --- a/boehm_gc/Makefile.direct
    +++ b/boehm_gc/Makefile.direct
    @@ -359,17 +359,18 @@ lib$(GC_GRADE).so: $(OBJS) $(UTILS) # dyn_load_sunos53.o
     	./if_mach SPARC SOLARIS $(MAKE) dyn_load_sunos53.o
     	./if_mach SPARC SOLARIS \
     	$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load_sunos53.o \
    -		-ldl $(MAYBE_THREAD_LIBS)
    +		-ldl $(MAYBE_THREAD_LIBS) $(EXTRA_LDFLAGS)
     	./if_not_there on_sparc_sunos5_so $(MAKE) dyn_load.o
     	./if_not_there on_sparc_sunos5_so \
     	$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load.o \
    -		-lc $(MAYBE_THREAD_LIBS)
    +		-lc $(MAYBE_THREAD_LIBS) $(EXTRA_LDFLAGS)
     
     # Darwin shared library version of the gc.
     lib$(GC_GRADE).dylib: $(OBJS) $(UTILS)
     	$(LINK_SHARED_OBJ) -install_name \
     		$(FINAL_INSTALL_MERC_GC_LIB_DIR)/lib$(GC_GRADE).dylib \
    -		-o lib$(GC_GRADE).dylib $(OBJS) dyn_load.o -lc
    +		-o lib$(GC_GRADE).dylib $(OBJS) dyn_load.o \
    +		-lc $(EXTRA_LDFLAGS)
     
     # SunOS5 shared library version of the collector
     sunos5gc.so: $(OBJS) dyn_load_sunos53.o
    diff --git a/runtime/Mmakefile b/runtime/Mmakefile
    index f6908cf..4957d16 100644
    --- a/runtime/Mmakefile
    +++ b/runtime/Mmakefile
    @@ -392,7 +392,7 @@ lib$(RT_LIB_NAME).so: $(PIC_OBJS)
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(RT_LIB_NAME).so $(PIC_OBJS)			\
     		$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_GC_LIB_DIR)	\
    -		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
    +		$(ALL_LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     # For Darwin we should pass the -install_name option.
    @@ -401,7 +401,7 @@ lib$(RT_LIB_NAME).dylib: $(PIC_OBJS)
     		-o lib$(RT_LIB_NAME).dylib $(PIC_OBJS)			\
     		-install_name 						\
     			$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(RT_LIB_NAME).dylib \
    -		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
    +		$(ALL_LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     endif
    diff --git a/trace/Mmakefile b/trace/Mmakefile
    index 3138bba..47e8fa9 100644
    --- a/trace/Mmakefile
    +++ b/trace/Mmakefile
    @@ -273,14 +273,16 @@ lib$(TRACE_LIB_NAME).so: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).so
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(TRACE_LIB_NAME).so $(TRACE_PIC_OBJS)		\
     		$(RPATH_1)$(RPATH_2)					\
    -		$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS)		\
    +		$(ALL_LDFLAGS) $(TRACE_LDFLAGS)				\
    +		$(TRACE_LDLIBS) $(THREADLIBS)				\
     		$(SHARED_LIBS)
     
     lib$(EVENTSPEC_LIB_NAME).so: $(EVENTSPEC_PIC_OBJS)
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(EVENTSPEC_LIB_NAME).so $(EVENTSPEC_PIC_OBJS)	\
     		$(RPATH_1)$(RPATH_2)					\
    -		$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS)	\
    +		$(ALL_LDFLAGS) $(EVENTSPEC_LDFLAGS)			\
    +		$(EVENTSPEC_LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     # For Darwin:
    @@ -289,7 +291,8 @@ lib$(TRACE_LIB_NAME).dylib: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).dylib
     		-o lib$(TRACE_LIB_NAME).dylib $(TRACE_PIC_OBJS)		\
     		-install_name 						\
     		$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(TRACE_LIB_NAME).dylib \
    -		$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS)		\
    +		$(ALL_LDFLAGS) $(TRACE_LDFLAGS)				\
    +		$(TRACE_LDLIBS) $(THREADLIBS)				\
     		$(SHARED_LIBS)
     
     lib$(EVENTSPEC_LIB_NAME).dylib: $(EVENTSPEC_PIC_OBJS)
    @@ -297,7 +300,8 @@ lib$(EVENTSPEC_LIB_NAME).dylib: $(EVENTSPEC_PIC_OBJS)
     		-o lib$(EVENTSPEC_LIB_NAME).dylib $(EVENTSPEC_PIC_OBJS)	\
     		-install_name 						\
     		$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(EVENTSPEC_LIB_NAME).dylib \
    -		$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS)	\
    +		$(ALL_LDFLAGS) $(EVENTSPEC_LDFLAGS)			\
    +		$(EVENTSPEC_LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     .PHONY: cs
    diff --git a/util/Mmakefile b/util/Mmakefile
    index c3ff7aa..80ba6d2 100644
    --- a/util/Mmakefile
    +++ b/util/Mmakefile
    @@ -51,30 +51,30 @@ all:	$(PROGFILENAMES) $(TAGS_FILE_EXISTS)
     ifeq ($(USING_MICROSOFT_CL_COMPILER),yes)
     .c$(EXT_FOR_EXE):
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ $< $(GETOPT_SRC)
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ $< $(GETOPT_SRC)
     
     mkinit$(EXT_FOR_EXE): mkinit.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ \
     			mkinit.c mkinit_common.c $(GETOPT_SRC)
     
     mkinit_erl$(EXT_FOR_EXE): mkinit_erl.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ \
     			mkinit_erl.c mkinit_common.c $(GETOPT_SRC)
     else
     .c$(EXT_FOR_EXE):
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ $< $(GETOPT_SRC)
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ $< $(GETOPT_SRC)
     
     mkinit$(EXT_FOR_EXE): mkinit.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ \
     			mkinit.c mkinit_common.c $(GETOPT_SRC)
     
     mkinit_erl$(EXT_FOR_EXE): mkinit_erl.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ \
     			mkinit_erl.c mkinit_common.c $(GETOPT_SRC)
     
     endif
    
    patch file icon mercury-linker-flags.patch (5,206 bytes) 2013-06-04 03:27 +
  • patch file icon mercury-linker-flags-v2.patch (5,242 bytes) 2013-06-07 00:19 -
    diff --git a/boehm_gc/Makefile.direct b/boehm_gc/Makefile.direct
    index 373bf84..97a43a7 100644
    --- a/boehm_gc/Makefile.direct
    +++ b/boehm_gc/Makefile.direct
    @@ -359,11 +359,11 @@ lib$(GC_GRADE).so: $(OBJS) $(UTILS) # dyn_load_sunos53.o
     	./if_mach SPARC SOLARIS $(MAKE) dyn_load_sunos53.o
     	./if_mach SPARC SOLARIS \
     	$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load_sunos53.o \
    -		-ldl $(MAYBE_THREAD_LIBS)
    +		-ldl $(MAYBE_THREAD_LIBS) $(LD_LIBFLAGS) $(EXTRA_LD_LIBFLAGS)
     	./if_not_there on_sparc_sunos5_so $(MAKE) dyn_load.o
     	./if_not_there on_sparc_sunos5_so \
     	$(LINK_SHARED_OBJ) -o lib$(GC_GRADE).so $(OBJS) dyn_load.o \
    -		-lc $(MAYBE_THREAD_LIBS)
    +		-lc $(MAYBE_THREAD_LIBS) $(LD_LIBFLAGS) $(EXTRA_LD_LIBFLAGS)
     
     # Darwin shared library version of the gc.
     lib$(GC_GRADE).dylib: $(OBJS) $(UTILS)
    diff --git a/runtime/Mmakefile b/runtime/Mmakefile
    index f6908cf..6d9c672 100644
    --- a/runtime/Mmakefile
    +++ b/runtime/Mmakefile
    @@ -248,7 +248,7 @@ MGNUCFLAGS	+= --c-debug --no-ansi
     OBJS		= $(CFILES:.c=.$O)
     PIC_OBJS	= $(CFILES:.c=.$(EXT_FOR_PIC_OBJECTS))
     
    -LDFLAGS		= -L$(BOEHM_GC_DIR) -L/usr/local/lib
    +LD_LIBFLAGS	= -L$(BOEHM_GC_DIR) -L/usr/local/lib
     LDLIBS		= $(SHARED_GC_LIBS) $(MATH_LIB)
     
     THREADLIBS	= \
    @@ -392,7 +392,7 @@ lib$(RT_LIB_NAME).so: $(PIC_OBJS)
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(RT_LIB_NAME).so $(PIC_OBJS)			\
     		$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_GC_LIB_DIR)	\
    -		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
    +		$(ALL_LD_LIBFLAGS) $(LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     # For Darwin we should pass the -install_name option.
    @@ -401,7 +401,7 @@ lib$(RT_LIB_NAME).dylib: $(PIC_OBJS)
     		-o lib$(RT_LIB_NAME).dylib $(PIC_OBJS)			\
     		-install_name 						\
     			$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(RT_LIB_NAME).dylib \
    -		$(LDFLAGS) $(LDLIBS) $(THREADLIBS)			\
    +		$(ALL_LD_LIBFLAGS) $(LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     endif
    diff --git a/trace/Mmakefile b/trace/Mmakefile
    index 3138bba..79e00c4 100644
    --- a/trace/Mmakefile
    +++ b/trace/Mmakefile
    @@ -273,14 +273,16 @@ lib$(TRACE_LIB_NAME).so: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).so
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(TRACE_LIB_NAME).so $(TRACE_PIC_OBJS)		\
     		$(RPATH_1)$(RPATH_2)					\
    -		$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS)		\
    +		$(ALL_LD_LIBFLAGS) $(TRACE_LDFLAGS)			\
    +		$(TRACE_LDLIBS) $(THREADLIBS)				\
     		$(SHARED_LIBS)
     
     lib$(EVENTSPEC_LIB_NAME).so: $(EVENTSPEC_PIC_OBJS)
     	$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED)				\
     		-o lib$(EVENTSPEC_LIB_NAME).so $(EVENTSPEC_PIC_OBJS)	\
     		$(RPATH_1)$(RPATH_2)					\
    -		$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS)	\
    +		$(ALL_LD_LIBFLAGS) $(EVENTSPEC_LDFLAGS)			\
    +		$(EVENTSPEC_LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     # For Darwin:
    @@ -289,7 +291,8 @@ lib$(TRACE_LIB_NAME).dylib: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).dylib
     		-o lib$(TRACE_LIB_NAME).dylib $(TRACE_PIC_OBJS)		\
     		-install_name 						\
     		$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(TRACE_LIB_NAME).dylib \
    -		$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS)		\
    +		$(ALL_LD_LIBFLAGS) $(TRACE_LDFLAGS)			\
    +		$(TRACE_LDLIBS) $(THREADLIBS)				\
     		$(SHARED_LIBS)
     
     lib$(EVENTSPEC_LIB_NAME).dylib: $(EVENTSPEC_PIC_OBJS)
    @@ -297,7 +300,8 @@ lib$(EVENTSPEC_LIB_NAME).dylib: $(EVENTSPEC_PIC_OBJS)
     		-o lib$(EVENTSPEC_LIB_NAME).dylib $(EVENTSPEC_PIC_OBJS)	\
     		-install_name 						\
     		$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(EVENTSPEC_LIB_NAME).dylib \
    -		$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS)	\
    +		$(ALL_LD_LIBFLAGS) $(EVENTSPEC_LDFLAGS)			\
    +		$(EVENTSPEC_LDLIBS) $(THREADLIBS)			\
     		$(SHARED_LIBS)
     
     .PHONY: cs
    diff --git a/util/Mmakefile b/util/Mmakefile
    index c3ff7aa..80ba6d2 100644
    --- a/util/Mmakefile
    +++ b/util/Mmakefile
    @@ -51,30 +51,30 @@ all:	$(PROGFILENAMES) $(TAGS_FILE_EXISTS)
     ifeq ($(USING_MICROSOFT_CL_COMPILER),yes)
     .c$(EXT_FOR_EXE):
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ $< $(GETOPT_SRC)
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ $< $(GETOPT_SRC)
     
     mkinit$(EXT_FOR_EXE): mkinit.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ \
     			mkinit.c mkinit_common.c $(GETOPT_SRC)
     
     mkinit_erl$(EXT_FOR_EXE): mkinit_erl.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -Fe$@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -Fe$@ \
     			mkinit_erl.c mkinit_common.c $(GETOPT_SRC)
     else
     .c$(EXT_FOR_EXE):
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ $< $(GETOPT_SRC)
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ $< $(GETOPT_SRC)
     
     mkinit$(EXT_FOR_EXE): mkinit.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ \
     			mkinit.c mkinit_common.c $(GETOPT_SRC)
     
     mkinit_erl$(EXT_FOR_EXE): mkinit_erl.c mkinit_common.c mkinit_common.h
     	$(MGNUC) --no-mercury-stdlib-dir \
    -		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) -o $@ \
    +		$(GRADEFLAGS) $(ALL_MGNUCFLAGS) $(ALL_LDFLAGS) -o $@ \
     			mkinit_erl.c mkinit_common.c $(GETOPT_SRC)
     
     endif
    
    patch file icon mercury-linker-flags-v2.patch (5,242 bytes) 2013-06-07 00:19 +

-Relationships
+Relationships

-Notes

~0000535

juliensf (administrator)

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 (reporter)

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 (administrator)

Committed, along with some additions to support the same for .dylib files properly.
+Notes

-Issue History
Date Modified Username Field Change
2013-06-04 03:27 keri New Issue
2013-06-04 03:27 keri File Added: mercury-linker-flags.patch
2013-06-05 16:09 juliensf Note Added: 0000535
2013-06-07 00:19 keri File Added: mercury-linker-flags-v2.patch
2013-06-07 00:20 keri Note Added: 0000537
2013-06-20 18:02 juliensf Assigned To => juliensf
2013-06-20 18:02 juliensf Status new => assigned
2013-06-24 11:12 juliensf Note Added: 0000543
2013-06-24 11:12 juliensf Status assigned => resolved
2013-06-24 11:12 juliensf Resolution open => fixed
+Issue History