Skip to content

Commit

Permalink
rust: add some kludges to better support NetBSD HEAD-llvm
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tnn2 authored and Jonathan Perkin committed Jun 20, 2019
1 parent c4c10e3 commit 096d69d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lang/rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.72 2019/01/03 03:12:30 tnn Exp $
# $NetBSD: Makefile,v 1.73 2019/01/05 23:29:40 tnn Exp $

DISTNAME= rustc-1.31.1-src
PKGREVISION= 1
Expand Down Expand Up @@ -308,10 +308,18 @@ post-extract:
MAKE_ENV+= OPENSSL_DIR=${SSLBASE}
.endif

.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
BUILDLINK_TRANSFORM+= rm:-lgcc_s
MAKE_ENV+= PKGSRC_HAVE_LIBCPP=yes
.endif

pre-build: pre-build-fix
# Requires libssh2 defines only available in master.
# Requires libssh2 defines only available in master.
${CP} -f ${WRKSRC}/src/vendor/libssh2-sys/libssh2/include/libssh2.h \
${BUILDLINK_DIR}/include/
.if ${OPSYS} == "NetBSD" && !empty(PKGSRC_COMPILER:Mclang) && !exists(/lib/libgcc_s.so)
cp ${FILESDIR}/libgcc_s.so.1 ${RUST_BOOTSTRAP_PATH}/lib/.
.endif

do-build:
cd ${WRKSRC} \
Expand Down
4 changes: 3 additions & 1 deletion lang/rust/distinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.50 2018/12/21 23:12:34 he Exp $
$NetBSD: distinfo,v 1.51 2019/01/05 23:29:40 tnn Exp $

SHA1 (rust-1.30.0-x86_64-sun-solaris.tar.gz) = d1da4a02bdbb9a46587bc64d4b7987bb3f1aaeab
RMD160 (rust-1.30.0-x86_64-sun-solaris.tar.gz) = 0670575ad4eb63f86d34299104f451463e5fc070
Expand Down Expand Up @@ -103,9 +103,11 @@ SHA1 (patch-src_bootstrap_lib.rs) = d86e173b931099730a4f18d044d7977c89f87b91
SHA1 (patch-src_libbacktrace_configure) = b2c1e9b93a99408aad42ab9f1af27704cc81bdd8
SHA1 (patch-src_liblibc_src_unix_bsd_netbsdlike_netbsd_mod.rs) = e5b564bb247094cc8e4e6935a02262b3385cb7e6
SHA1 (patch-src_liblibc_src_unix_solaris_mod.rs) = aeb7c22995e33c700ce3ea4336368a1fd08120e1
SHA1 (patch-src_librustc__llvm_build.rs) = a56bf5435e40bb012641ada6b20256901a1073fb
SHA1 (patch-src_libstd_build.rs) = 1edbf87339bd88e3178d4fa2fc408a6e802ed488
SHA1 (patch-src_libstd_sys_unix_thread.rs) = 46ef46365658e2f895bd3dde9c74f352890e9ccc
SHA1 (patch-src_libsyntax__pos_span__encoding.rs) = c891cffab8ae47b13b3b391ddd1a6c62ee2b38f3
SHA1 (patch-src_libunwind_build.rs) = 74e2101f0cd78ca68b0a9d14355e20dcaea66100
SHA1 (patch-src_llvm_CMakeLists.txt) = ffdf4337fdc84d8314c97c4e492e6b84244a99d1
SHA1 (patch-src_llvm_cmake_modules_AddLLVM.cmake) = f0620ac62ecfb1d62d2dfa61b4c063d21c29b8f5
SHA1 (patch-src_llvm_include_llvm-c_DataTypes.h) = 432693204912e79059ee31e815ad1e24f3236374
Expand Down
26 changes: 26 additions & 0 deletions lang/rust/patches/patch-src_librustc__llvm_build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$NetBSD: patch-src_librustc__llvm_build.rs,v 1.1 2019/01/05 23:29:40 tnn Exp $

fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.

--- src/librustc_llvm/build.rs.orig 2018-12-18 23:11:17.000000000 +0000
+++ src/librustc_llvm/build.rs
@@ -250,9 +250,17 @@ fn main() {
"c++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
// NetBSD uses a separate library when relocation is required
- "stdc++_pic"
+ if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
+ "c++_pic"
+ } else {
+ "stdc++_pic"
+ }
} else {
- "stdc++"
+ if env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
+ "c++"
+ } else {
+ "stdc++"
+ }
};

// C++ runtime library
17 changes: 17 additions & 0 deletions lang/rust/patches/patch-src_libunwind_build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$NetBSD: patch-src_libunwind_build.rs,v 1.1 2019/01/05 23:29:40 tnn Exp $

fix build on NetBSD HEAD-llvm. XXX there is probably a better way to do this.

--- src/libunwind/build.rs.orig 2018-12-18 23:11:17.000000000 +0000
+++ src/libunwind/build.rs
@@ -25,7 +25,9 @@ fn main() {
} else if target.contains("rumprun") {
println!("cargo:rustc-link-lib=unwind");
} else if target.contains("netbsd") {
- println!("cargo:rustc-link-lib=gcc_s");
+ if !env::var_os("PKGSRC_HAVE_LIBCPP").is_some() {
+ println!("cargo:rustc-link-lib=gcc_s");
+ }
} else if target.contains("openbsd") {
println!("cargo:rustc-link-lib=c++abi");
} else if target.contains("solaris") {

0 comments on commit 096d69d

Please sign in to comment.