Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157391252
D32654.id97496.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D32654.id97496.diff
View Options
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -50,17 +50,23 @@
# ?= to allow users to still overwrite it in make.conf.
TMPDIR?= ${WRKDIR}
-OPTIONS_DEFINE= DOCS GDB SOURCES WASM
+OPTIONS_DEFINE= DOCS GDB PORT_LLVM SOURCES WASM
OPTIONS_DEFAULT= SOURCES WASM
OPTIONS_EXCLUDE_armv6= DOCS
GDB_DESC= Install ports gdb (necessary for debugging rust programs)
+PORT_LLVM_DESC= Build against devel/llvm${LLVM_VER} (experimental)
SOURCES_DESC= Install source files
WASM_DESC= Build the WebAssembly target (wasm32-unknown-unknown)
DOCS_VARS= _RUST_BUILD_DOCS=true
DOCS_VARS_OFF= _RUST_BUILD_DOCS=false
GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb
+LLVM_VER= 13 # chase bundled LLVM
+PORT_LLVM_EXTRA_PATCHES=${PATCHDIR}/extra-patch-nopie
+PORT_LLVM_BUILD_DEPENDS=llvm-config${LLVM_VER}:devel/llvm${LLVM_VER}
+PORT_LLVM_LIB_DEPENDS= libLLVM-${LLVM_VER}.so:devel/llvm${LLVM_VER}
+PORT_LLVM_VARS= MAKE_ENV+=RUSTFLAGS="-Lnative=${LOCALBASE}/lib -Clink-arg=-no-pie"
SOURCES_VARS= _RUST_TOOLS+=src
WASM_VARS= _RUST_BUILD_WASM=true \
_RUST_TARGETS+=wasm32-unknown-unknown
@@ -204,6 +210,9 @@
.else
@${ECHO_CMD} 'linker="${CC}"' >> ${WRKSRC}/config.toml
.endif
+.if ${PORT_OPTIONS:MPORT_LLVM}
+ @${ECHO_CMD} 'llvm-config="${LOCALBASE}/llvm${LLVM_VER}/bin/llvm-config"' >> ${WRKSRC}/config.toml
+.endif
.endfor
@${ECHO_CMD} '[dist]' >> ${WRKSRC}/config.toml
@${ECHO_CMD} 'src-tarball=false' >> ${WRKSRC}/config.toml
diff --git a/lang/rust/files/extra-patch-nopie b/lang/rust/files/extra-patch-nopie
new file mode 100644
--- /dev/null
+++ b/lang/rust/files/extra-patch-nopie
@@ -0,0 +1,30 @@
+diff --git compiler/rustc_codegen_ssa/src/back/linker.rs compiler/rustc_codegen_ssa/src/back/linker.rs
+index 9e1c6a1..0425197 100644
+--- compiler/rustc_codegen_ssa/src/back/linker.rs
++++ compiler/rustc_codegen_ssa/src/back/linker.rs
+@@ -349,7 +349,7 @@ impl<'a> Linker for GccLinker<'a> {
+ // noop on windows w/ gcc & ld, error w/ lld
+ if !self.sess.target.is_like_windows {
+ // `-pie` works for both gcc wrapper and ld.
+- self.cmd.arg("-pie");
++ self.cmd.arg("-no-pie");
+ }
+ }
+ LinkOutputKind::StaticNoPicExe => {
+@@ -363,14 +363,14 @@ impl<'a> Linker for GccLinker<'a> {
+ if !self.is_ld {
+ // Note that combination `-static -pie` doesn't work as expected
+ // for the gcc wrapper, `-static` in that case suppresses `-pie`.
+- self.cmd.arg("-static-pie");
++ self.cmd.arg("-static");
+ } else {
+ // `--no-dynamic-linker` and `-z text` are not strictly necessary for producing
+ // a static pie, but currently passed because gcc and clang pass them.
+ // The former suppresses the `INTERP` ELF header specifying dynamic linker,
+ // which is otherwise implicitly injected by ld (but not lld).
+ // The latter doesn't change anything, only ensures that everything is pic.
+- self.cmd.args(&["-static", "-pie", "--no-dynamic-linker", "-z", "text"]);
++ self.cmd.args(&["-static", "-no-pie", "--no-dynamic-linker", "-z", "text"]);
+ }
+ }
+ LinkOutputKind::DynamicDylib => self.build_dylib(out_filename),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 21, 10:25 PM (2 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33407173
Default Alt Text
D32654.id97496.diff (3 KB)
Attached To
Mode
D32654: lang/rust: restore PORT_LLVM
Attached
Detach File
Event Timeline
Log In to Comment