Skip to content

Commit

Permalink
lang/rust: fix build on powerpc on FreeBSD 13.1 and newer
Browse files Browse the repository at this point in the history
1. When building with RUST_BACKTRACE=1, cargo segfaults:
pre-installed rustc not detected: [Errno 2] No such file or directory: 'rustc'
falling back to auto-detect
warning: sqlite3 not available in python, skipping build directory lock
please file an issue on rust-lang/rust
this is not a problem for non-concurrent x.py invocations
Building rustbuild
running: /wrkdirs/usr/ports/lang/rust/work/bootstrap/bin/cargo build --manifest-path /wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/Cargo.toml --verbose --verbose --frozen
Traceback (most recent call last):
  File "x.py", line 27, in <module>
    bootstrap.main()
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/bootstrap.py", line 1313, in main
    bootstrap(help_triggered)
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/bootstrap.py", line 1284, in bootstrap
    build.build_bootstrap()
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/bootstrap.py", line 1031, in build_bootstrap
    run(args, env=env, verbose=self.verbose)
  File "/wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/bootstrap.py", line 182, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /wrkdirs/usr/ports/lang/rust/work/bootstrap/bin/cargo build --manifest-path /wrkdirs/usr/ports/lang/rust/work/rustc-1.59.0-src/src/bootstrap/Cargo.toml --verbose --verbose --frozen

From dmesg:
pid 27701 (cargo), jid 198, uid 0: exited on signal 11

2. Builds with the base LLVM 13 fail:
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xB0): relocation R_PPC_PLTREL24 out of range: -33582208 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xC8): relocation R_PPC_PLTREL24 out of range: -33582232 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0x1A0): relocation R_PPC_PLTREL24 out of range: -33582448 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0x2B8): relocation R_PPC_PLTREL24 out of range: -33582728 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0x2FC): relocation R_PPC_PLTREL24 out of range: -33582796 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0x348): relocation R_PPC_PLTREL24 out of range: -33582872 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function _GLOBAL__sub_I_CallSiteSplitting.cpp: .text._GLOBAL__sub_I_CallSiteSplitting.cpp+0x80): relocation R_PPC_PLTREL24 out of range: -33583000 is not in [-33554432, 33554431]
ld: error: CallSiteSplitting.cpp:(function _GLOBAL__sub_I_CallSiteSplitting.cpp: .text._GLOBAL__sub_I_CallSiteSplitting.cpp+0xB0): relocation R_PPC_PLTREL24 out of range: -33583208 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::initializeConstantHoistingLegacyPassPass(llvm::PassRegistry&): .text._ZN4llvm40initializeConstantHoistingLegacyPassPassERNS_12PassRegistryE+0x94): relocation R_PPC_PLTREL24 out of range: -33583360 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function initializeConstantHoistingLegacyPassPassOnce(llvm::PassRegistry&): .text._ZL44initializeConstantHoistingLegacyPassPassOnceRN4llvm12PassRegistryE+0x50): relocation R_PPC_PLTREL24 out of range: -33583396 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::createConstantHoistingPass(): .text._ZN4llvm26createConstantHoistingPassEv+0x3C): relocation R_PPC_PLTREL24 out of range: -33583584 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::createConstantHoistingPass(): .text._ZN4llvm26createConstantHoistingPassEv+0x78): relocation R_PPC_PLTREL24 out of range: -33583548 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::createConstantHoistingPass(): .text._ZN4llvm26createConstantHoistingPassEv+0x98): relocation R_PPC_PLTREL24 out of range: -33583580 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::createConstantHoistingPass(): .text._ZN4llvm26createConstantHoistingPassEv+0x118): relocation R_PPC_PLTREL24 out of range: -33583852 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::ConstantHoistingPass::findConstantInsertionPoint(llvm::consthoist::ConstantInfo const&) const: .text._ZNK4llvm20ConstantHoistingPass26findConstantInsertionPointERKNS_10consthoist12ConstantInfoE+0x240): relocation R_PPC_PLTREL24 out of range: -33584892 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::ConstantHoistingPass::findConstantInsertionPoint(llvm::consthoist::ConstantInfo const&) const: .text._ZNK4llvm20ConstantHoistingPass26findConstantInsertionPointERKNS_10consthoist12ConstantInfoE+0x270): relocation R_PPC_PLTREL24 out of range: -33584924 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::ConstantHoistingPass::findConstantInsertionPoint(llvm::consthoist::ConstantInfo const&) const: .text._ZNK4llvm20ConstantHoistingPass26findConstantInsertionPointERKNS_10consthoist12ConstantInfoE+0x294): relocation R_PPC_PLTREL24 out of range: -33584944 is not in [-33554432, 33554431]
ld: error: ConstantHoisting.cpp:(function llvm::ConstantHoistingPass::findConstantInsertionPoint(llvm::consthoist::ConstantInfo const&) const: .text._ZNK4llvm20ConstantHoistingPass26findConstantInsertionPointERKNS_10consthoist12ConstantInfoE+0x90C): relocation R_PPC_PLTREL24 out of range: -33586536 is not in [-33554432, 33554431]

Use LLVM 12 to build.
  • Loading branch information
pkubaj committed Mar 23, 2022
1 parent 355919d commit c6547a4
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lang/rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ CPE_VENDOR= rust-lang

MAKE_ENV= DESTDIR=${STAGEDIR} \
LIBGIT2_NO_PKG_CONFIG=1 \
OPENSSL_DIR="${OPENSSLBASE}" \
RUST_BACKTRACE=1
OPENSSL_DIR="${OPENSSLBASE}"
TEST_ENV= ${MAKE_ENV} \
ALLOW_NONZERO_RLIMIT_CORE=1

Expand Down Expand Up @@ -96,8 +95,16 @@ IGNORE= is only for FreeBSD

.if ${ARCH} == powerpc
# bfd to link rustc_driver; lld currently can't
BUILD_DEPENDS+= ld.bfd:devel/binutils
BUILD_DEPENDS+= ld.bfd:devel/binutils \
clang12:devel/llvm12
BINARY_ALIAS+= cpp=${LOCALBASE}/bin/clang-cpp12 \
cc=${LOCALBASE}/bin/clang12 \
c++=${LOCALBASE}/bin/clang++12 \
ar=${LOCALBASE}/bin/llvm-ar12 \
nm=${LOCALBASE}/bin/llvm-nm12 \
ld=${LOCALBASE}/bin/ld.lld12
.else
MAKE_ENV+= RUST_BACKTRACE=1
# rls needs 64-bit atomics
_RUST_TOOLS+= rls
.endif
Expand Down

0 comments on commit c6547a4

Please sign in to comment.