Skip to content

Commit 096d69d

Browse files
tnn2jperkin
authored andcommitted
rust: add some kludges to better support NetBSD HEAD-llvm
1) bootstrap rustc adds -lgcc_s when linking -> Dropped with a BUILDLINK_TRANSFORM 2) bootstrap rustc has shared linkage to libgcc_s.so.1 -> Until upstream changes this to static linkage, we look for libgcc_s.so.1 in ${FILESDIR} where the user must place it manually. 3) newly built rustc adds -lstdc++ instead of -lc++ when linking llvm -> fixed with patch-src_librustc__llvm_build.rs 4) newly built rustc adds -lgcc_s when linking -> fixed with patch-src_libunwind_build.rs
1 parent c4c10e3 commit 096d69d

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

lang/rust/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: Makefile,v 1.72 2019/01/03 03:12:30 tnn Exp $
1+
# $NetBSD: Makefile,v 1.73 2019/01/05 23:29:40 tnn Exp $
22

33
DISTNAME= rustc-1.31.1-src
44
PKGREVISION= 1
@@ -308,10 +308,18 @@ post-extract:
308308
MAKE_ENV+= OPENSSL_DIR=${SSLBASE}
309309
.endif
310310

311+
.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
312+
BUILDLINK_TRANSFORM+= rm:-lgcc_s
313+
MAKE_ENV+= PKGSRC_HAVE_LIBCPP=yes
314+
.endif
315+
311316
pre-build: pre-build-fix
312-
# Requires libssh2 defines only available in master.
317+
# Requires libssh2 defines only available in master.
313318
${CP} -f ${WRKSRC}/src/vendor/libssh2-sys/libssh2/include/libssh2.h \
314319
${BUILDLINK_DIR}/include/
320+
.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
321+
cp ${FILESDIR}/libgcc_s.so.1 ${RUST_BOOTSTRAP_PATH}/lib/.
322+
.endif
315323

316324
do-build:
317325
cd ${WRKSRC} \

lang/rust/distinfo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$NetBSD: distinfo,v 1.50 2018/12/21 23:12:34 he Exp $
1+
$NetBSD: distinfo,v 1.51 2019/01/05 23:29:40 tnn Exp $
22

33
SHA1 (rust-1.30.0-x86_64-sun-solaris.tar.gz) = d1da4a02bdbb9a46587bc64d4b7987bb3f1aaeab
44
RMD160 (rust-1.30.0-x86_64-sun-solaris.tar.gz) = 0670575ad4eb63f86d34299104f451463e5fc070
@@ -103,9 +103,11 @@ SHA1 (patch-src_bootstrap_lib.rs) = d86e173b931099730a4f18d044d7977c89f87b91
103103
SHA1 (patch-src_libbacktrace_configure) = b2c1e9b93a99408aad42ab9f1af27704cc81bdd8
104104
SHA1 (patch-src_liblibc_src_unix_bsd_netbsdlike_netbsd_mod.rs) = e5b564bb247094cc8e4e6935a02262b3385cb7e6
105105
SHA1 (patch-src_liblibc_src_unix_solaris_mod.rs) = aeb7c22995e33c700ce3ea4336368a1fd08120e1
106+
SHA1 (patch-src_librustc__llvm_build.rs) = a56bf5435e40bb012641ada6b20256901a1073fb
106107
SHA1 (patch-src_libstd_build.rs) = 1edbf87339bd88e3178d4fa2fc408a6e802ed488
107108
SHA1 (patch-src_libstd_sys_unix_thread.rs) = 46ef46365658e2f895bd3dde9c74f352890e9ccc
108109
SHA1 (patch-src_libsyntax__pos_span__encoding.rs) = c891cffab8ae47b13b3b391ddd1a6c62ee2b38f3
110+
SHA1 (patch-src_libunwind_build.rs) = 74e2101f0cd78ca68b0a9d14355e20dcaea66100
109111
SHA1 (patch-src_llvm_CMakeLists.txt) = ffdf4337fdc84d8314c97c4e492e6b84244a99d1
110112
SHA1 (patch-src_llvm_cmake_modules_AddLLVM.cmake) = f0620ac62ecfb1d62d2dfa61b4c063d21c29b8f5
111113
SHA1 (patch-src_llvm_include_llvm-c_DataTypes.h) = 432693204912e79059ee31e815ad1e24f3236374
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$NetBSD: patch-src_librustc__llvm_build.rs,v 1.1 2019/01/05 23:29:40 tnn Exp $
2+
3+
fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.
4+
5+
--- src/librustc_llvm/build.rs.orig 2018-12-18 23:11:17.000000000 +0000
6+
+++ src/librustc_llvm/build.rs
7+
@@ -250,9 +250,17 @@ fn main() {
8+
"c++"
9+
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
10+
// NetBSD uses a separate library when relocation is required
11+
- "stdc++_pic"
12+
+ if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
13+
+ "c++_pic"
14+
+ } else {
15+
+ "stdc++_pic"
16+
+ }
17+
} else {
18+
- "stdc++"
19+
+ if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
20+
+ "c++"
21+
+ } else {
22+
+ "stdc++"
23+
+ }
24+
};
25+
26+
// C++ runtime library
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$NetBSD: patch-src_libunwind_build.rs,v 1.1 2019/01/05 23:29:40 tnn Exp $
2+
3+
fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.
4+
5+
--- src/libunwind/build.rs.orig 2018-12-18 23:11:17.000000000 +0000
6+
+++ src/libunwind/build.rs
7+
@@ -25,7 +25,9 @@ fn main() {
8+
} else if target.contains("rumprun") {
9+
println!("cargo:rustc-link-lib=unwind");
10+
} else if target.contains("netbsd") {
11+
- println!("cargo:rustc-link-lib=gcc_s");
12+
+ if !env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
13+
+ println!("cargo:rustc-link-lib=gcc_s");
14+
+ }
15+
} else if target.contains("openbsd") {
16+
println!("cargo:rustc-link-lib=c++abi");
17+
} else if target.contains("solaris") {

0 commit comments

Comments
 (0)