pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Rust still broken on 9.0-STABLE i386



>>> I'm now taking a different tack, in that I'm trying to
>>> cross-build a bootstrap kit for i386 where I've tweaked the
>>> "gcc-wrap" script to link a list of known external libraries
>>> statically -- we'll see how that goes.
>>
>> It's great that you are working on this, but I am trying to do
>> something simple and non-scary to get the package to build.  If
>> you have a better fix and want to use your fix instead, happy
>> to consider it.
> 
> I'm trying to make it as simple, non-intrusive and non-scary as
> possible.  It's only going to affect the cross-building
> machinery, plus (if I manage to complete it) at least the i386
> bootstrap.

Attached is a diff which caused my attempted mostly-static cross
build for i386 to succeed.  This is an optional thing, not
enabled by default, ref. the commented-out remark, and only works
in conjunction with the modified gcc-wrap script, which is only
used when cross-building.  I'm currently uploading the build
result, it'll be a while till it's there.

Regards,

- Håvard
Index: cross.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/cross.mk,v
retrieving revision 1.3
diff -u -r1.3 cross.mk
--- cross.mk	16 Jul 2020 09:35:37 -0000	1.3
+++ cross.mk	21 Sep 2020 10:37:47 -0000
@@ -49,6 +49,10 @@
 # May be required when cross-building on NetBSD
 #MAKE_ENV+=		OPENSSL_DIR=/usr
 
+# Link statically with external libraries (curl++, crypto, ssl, ...)
+# For details, see code in files/gcc-wrap
+#MAKE_ENV+=		STATIC_EXTERNALS=true
+
 #
 # Cross-compile illumos target.  The host is identical, it's just the target
 # that is renamed from x86_64-sun-solaris to x86_64-unknown-illumos.
Index: files/gcc-wrap
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/files/gcc-wrap,v
retrieving revision 1.4
diff -u -r1.4 gcc-wrap
--- files/gcc-wrap	21 Dec 2018 23:12:34 -0000	1.4
+++ files/gcc-wrap	21 Sep 2020 10:37:47 -0000
@@ -8,6 +8,11 @@
 # ...or the native root, when we don't cross-compile
 root=${CROSS_ROOT:-/}
 
+static_externals=${STATIC_EXTERNALS:-false}
+
+external_libs="ssl crypto stdc++ curl"
+must_be_dynamic="gcc_s"
+
 native=false
 if [ $root = "/" ]; then
 	native=true
@@ -26,7 +31,7 @@
 # (perhaps this is overly cautious, other adjustments we do
 # below may be sufficient...)
 # Lib directories to ensure we search and have in run-path
-libs="/lib /usr/lib /usr/pkg/lib"
+libs="/usr/pkg/lib /usr/lib /lib"
 
 for d in $libs; do
 	if ! $native; then
@@ -93,7 +98,40 @@
 				args="$args $linkadd"
 				linktweaked=true
 			fi
-			args="$args $1"
+			tweaked=false
+			if $static_externals; then
+				libs="$1"
+				case "$1" in
+					-lcurl)
+						# add all nested dependencies
+						# in the right order since
+						# we're linking statically
+						libs="$1 -lnghttp2 -lidn2 -lunistring -lssl -lcrypto -lgssapi -lheimntlm -lkrb5 -lheimbase -lhx509 -lhcrypto -lasn1 -lwind -lcom_err -lroken -lsqlite3 -lcrypt"
+						;;
+					-lssl)
+						# reorder...
+						libs="-lcurl $1 -lcrypto";
+						;;
+				esac
+				for l in $external_libs; do
+					if [ "$1" = "-l$l" ]; then
+						args="$args -Wl,--start-group -Wl,-Bstatic $libs -Wl,--end-group"
+						tweaked=true
+					fi
+
+				done
+				for l in $must_be_dynamic; do
+					if [ "$1" = "-l$l" ]; then
+						args="$args -Wl,--start-group -Wl,-Bdynamic $1 -Wl,--end-group"
+						tweaked=true
+					fi
+				done
+				if ! $tweaked; then
+					args="$args $1"
+				fi
+			else
+				args="$args $1"
+			fi
 			;;
 		-L)
 			if ! $linktweaked; then


Home | Main Index | Thread Index | Old Index