Make shared libraries link properly with -Wl,--as-needed

This commit is contained in:
Orion Poplawski 2018-12-16 20:03:09 -07:00
parent 08782a2077
commit 838cd66eb9
3 changed files with 61 additions and 2 deletions

View File

@ -13,7 +13,8 @@ override CFLAGS += -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_FILE_COMPRESS_BZ2 -DCOMMO
-Drestrict=__restrict -DIDXSIZE64
CLIBFLAGS = -shared -fPIC
override LDFLAGS += -lz -lbz2 -llzma -lm -lrt -lpthread
ARFLAGS = -shared -Wl,-soname=$@.$(SOMAJ) $(LDFLAGS) -o
# LDFLAGS added to AR rule in Makefiles to come after objects to work with -Wl,--as-needed
ARFLAGS = -shared -Wl,-soname=$@.$(SOMAJ) -o
CP = cp -av
LEX = flex
LN = ln

53
scotch-ldflags.patch Normal file
View File

@ -0,0 +1,53 @@
diff -up scotch_6.0.6/src/libscotch/Makefile.ldflags scotch_6.0.6/src/libscotch/Makefile
--- scotch_6.0.6/src/libscotch/Makefile.ldflags 2018-07-14 09:24:49.000000000 -0600
+++ scotch_6.0.6/src/libscotch/Makefile 2018-12-16 11:51:17.539309609 -0700
@@ -3065,25 +3065,25 @@ ptscotchf.h : ptdummysizes$(EXE) \
./ptdummysizes$(EXE) "-s$(SCOTCH_NAME_SUFFIX)" library_pt_f.h ptscotchf.h
libscotch$(LIB) : $(LIBSCOTCHDEPS)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
libscotcherr$(LIB) : library_error$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
libscotcherrexit$(LIB) : library_error_exit$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
libptscotch$(LIB) : $(LIBPTSCOTCHDEPS)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
libptscotcherr$(LIB) : library_error_pt$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
libptscotcherrexit$(LIB) : library_error_exit_pt$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(?)
+ $(AR) $(ARFLAGS) $(@) $(?) $(LDFLAGS)
-$(RANLIB) $(@)
diff -up scotch_6.0.6/src/libscotchmetis/Makefile.ldflags scotch_6.0.6/src/libscotchmetis/Makefile
--- scotch_6.0.6/src/libscotchmetis/Makefile.ldflags 2018-07-14 09:24:49.000000000 -0600
+++ scotch_6.0.6/src/libscotchmetis/Makefile 2018-12-16 11:50:54.513988475 -0700
@@ -139,12 +139,12 @@ libptscotchparmetis$(LIB) : parmetis_dgr
parmetis_dgraph_order_f$(OBJ) \
parmetis_dgraph_part$(OBJ) \
parmetis_dgraph_part_f$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(^)
+ $(AR) $(ARFLAGS) $(@) $(^) $(LDFLAGS)
-$(RANLIB) $(@)
libscotchmetis$(LIB) : metis_graph_order$(OBJ) \
metis_graph_order_f$(OBJ) \
metis_graph_part$(OBJ) \
metis_graph_part_f$(OBJ)
- $(AR) $(ARFLAGS) $(@) $(^)
+ $(AR) $(ARFLAGS) $(@) $(^) $(LDFLAGS)
-$(RANLIB) $(@)

View File

@ -10,7 +10,7 @@
Name: scotch
Summary: Graph, mesh and hypergraph partitioning library
Version: 6.0.6
Release: 2%{?dist}
Release: 3%{?dist}
License: CeCILL-C
URL: https://gforge.inria.fr/projects/scotch/
@ -19,6 +19,8 @@ Source1: scotch-Makefile.shared.inc.in
# Makefile fix for installing esmumps
Patch0: scotch_esmumps.patch
# Make shared libraries link properly with -Wl,--as-needed
Patch1: scotch-ldflags.patch
BuildRequires: flex
BuildRequires: bison
@ -269,6 +271,9 @@ popd
%doc doc/scotch_example.f
%changelog
* Sun Dec 16 2018 Orion Poplawski <orion@cnwra.com> - 6.0.6-3
- Make shared libraries link properly with -Wl,--as-needed
* Sat Dec 1 2018 Orion Poplawski <orion@cnwra.com> - 6.0.6-2
- Drop BR lzma, use xz for lzma support