tech-pkg archive

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

Re: Rust on NetBSD 9



> The latest NetBSD 9 bulk build (on x86_64) has a Rust build failure:
>
> https://releng.netbsd.org/bulktracker/pkg/55017055
>
>    Compiling core v0.0.0
> (/pbulk/work/lang/rust/work/rustc-1.86.0-src/library/core)
> error: failed to parse bitcode for LTO module: Invalid alignment value
> (Producer: 'LLVM19.1.7' Reader: 'LLVM 19.1.7')

I have now after a detour via pkgsrc update reproduced this
problem.  This occurs only when rust is using an "external" LLVM
(which is the default), and is in my case observed with
NetBSD/amd64 9.3, like so:

Building stage1 library artifacts (x86_64-unknown-netbsd)
   Compiling shlex v1.3.0
   Compiling core v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.86.0-src/library/core)
   Compiling libc v0.2.169
   Compiling object v0.36.7
   Compiling cc v1.2.0
   Compiling std v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.86.0-src/library/std)
   Compiling compiler_builtins v0.1.146
   Compiling rustc-std-workspace-core v1.99.0 (/usr/pkgsrc/lang/rust/work/rustc-1.86.0-src/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.86.0-src/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling unwind v0.0.0 (/usr/pkgsrc/lang/rust/work/rustc-1.86.0-src/library/unwind)
error: failed to parse bitcode for LTO module: Invalid alignment value (Producer: 'LLVM19.1.7' Reader: 'LLVM 19.1.7')

   Compiling adler2 v2.0.0
error: could not compile `core` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `compiler_builtins` (lib) due to 1 previous error
error: could not compile `alloc` (lib) due to 1 previous error
Build completed unsuccessfully in 0:20:41
*** Error code 1

Now, as to why this happens I do not know at the moment.

My testing scoreboard contains

x NetBSD        9               i386 / llvm-18          native-build

i.e. this combination built OK.  So is this only a problem with
llvm-19, or is it exclusive to NetBSD/amd64 9.x?

My scoreboard also has

f NetBSD        9.0             ppc / llvm-19           native-build (can't find clap_derive crate)

which is a different problem.

One option could be to do

Index: options.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/options.mk,v
retrieving revision 1.46
diff -u -r1.46 options.mk
--- options.mk  17 Jun 2025 15:14:57 -0000      1.46
+++ options.mk  20 Jun 2025 19:12:52 -0000
@@ -40,6 +40,15 @@
 .  endif
 .endif
 
+# On NetBSD/amd64 9.x, there are problems using an
+# external LLVM 19 from pkgsrc:
+# error: failed to parse bitcode for LTO module: Invalid alignment
+#  value (Producer: 'LLVM19.1.7' Reader: 'LLVM 19.1.7')
+# Building with the internal LLVM works, though.
+.if ${MACHINE_PLATFORM:MNetBSD-9.*}
+PKG_SUGGESTED_OPTIONS+=                rust-internal-llvm
+.endif
+
 #
 # Use the internal copy of LLVM or the external one?
 #

but there is so far little coverage to support this for non-amd64
ports.  (I may have been lazy, or done testing before llvm 19 was
committed, and done testing with an external llvm-18 for a couple
of combinations, which has worked.)

Regards,

- Havard


Home | Main Index | Thread Index | Old Index