rust-lang / rust-lang/rust

Mis-use of -isystem in rust 1.91.0's LLVM with siphash header?

Open
#148,450 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug needs-triage T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Summary

I'm cross-building the rust compiler with the bundled LLVM, and part of that includes using the target's cross-compiler to compile LLVM. I am observing the same symptom as observed in #143508.

Command used

With lots of environment tweaking, in this case also for cross compilation:

python3.12 ./x.py dist -j 40
Expected behaviour

I expected the build to succeed.

Actual behaviour
/usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/src/llvm-project/llvm/lib/Support/SipHash.cpp:15:10: fatal error: siphash/SipHash.h: No such file or directory
 #include "siphash/SipHash.h"
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
Bootstrap configuration (bootstrap.toml)
profile = 'dist'
[llvm]
release-debuginfo = false
static-libstdcpp = false
ninja = false
targets = 'ARM;X86'
[gcc]
[build]
host = ['armv7-unknown-netbsd-eabihf']
target = ['armv7-unknown-netbsd-eabihf']
cargo = '/usr/pkgsrc/wip/rust191/work/rust-bootstrap/bin/cargo'
rustc = '/usr/pkgsrc/wip/rust191/work/rust-bootstrap/bin/rustc'
docs = false
compiler-docs = false
python = '/usr/pkg/bin/python3.12'
vendor = true
extended = true
cargo-native-static = true
configure-args = ['--prefix=/usr/pkg', '--mandir=/usr/pkg/man', '--sysconfdir=/usr/pkg/etc', '--python=/usr/pkg/bin/python3.12', '--release-channel=stable', '--local-rust-root=/usr/pkgsrc/wip/rust191/work/rust-bootstrap', '--enable-extended', '--enable-rpath', '--disable-codegen-tests', '--disable-compiler-docs', '--disable-llvm-static-stdcpp', '--disable-ninja', '--dist-compression-formats=xz', '--set', 'dist.vendor=false', '--host=armv7-unknown-netbsd-eabihf', '--target=armv7-unknown-netbsd-eabihf', '--set=target.armv7-unknown-netbsd-eabihf.cc=/usr/pkgsrc/wip/rust191/work/scripts/gcc-wrap', '--set=target.armv7-unknown-netbsd-eabihf.cxx=/usr/pkgsrc/wip/rust191/work/scripts/c++-wrap', '--set=target.armv7-unknown-netbsd-eabihf.linker=/usr/pkgsrc/wip/rust191/work/scripts/gcc-wrap', '--set=target.armv7-unknown-netbsd-eabihf.ar=/u/evbarm-armv7hf/tools/bin/armv7--netbsdelf-eabihf-ar', '--enable-vendor', '--disable-debug', '--disable-debug-assertions', '--disable-llvm-release-debuginfo', '--debuginfo-level=0', '--debuginfo-level-rustc=0', '--debuginfo-level-std=0', '--debuginfo-level-tools=0', '--debuginfo-level-tests=0', '--set', 'llvm.targets=ARM;X86', '--enable-cargo-native-static', '--disable-docs']
[install]
prefix = '/usr/pkg'
sysconfdir = '/usr/pkg/etc'
mandir = '/usr/pkg/man'
[rust]
debug = false
debug-assertions = false
debuginfo-level = 0
debuginfo-level-rustc = 0
debuginfo-level-std = 0
debuginfo-level-tools = 0
debuginfo-level-tests = 0
channel = 'stable'
rpath = true
codegen-tests = false
[dist]
compression-formats = ['xz']
vendor = false
[target.x86_64-unknown-netbsd]
[target.armv7-unknown-netbsd-eabihf]
cc = '/usr/pkgsrc/wip/rust191/work/scripts/gcc-wrap'
cxx = '/usr/pkgsrc/wip/rust191/work/scripts/c++-wrap'
ar = '/u/evbarm-armv7hf/tools/bin/armv7--netbsdelf-eabihf-ar'
linker = '/usr/pkgsrc/wip/rust191/work/scripts/gcc-wrap'
Operating system

Host: NetBSD/amd64 10.1

HEAD
$ echo `cat work/rustc-1.91.0-src/git-commit-hash`
f8297e351a40c1439a467bbbb6879088047f50b3
Additional context

This parituclar problem is an interaction between the new LLVM in rust 1.91.0 and the cross compilation rig I use to cross-build for the various NetBSD targets (e.g. armv7hf shown above).

In this setup, I need to use --sysroot=/... to point to the targets "system-supplied headers". Likewise, -isystem /some/path/ is rewritten to -isystem =/some/path. This means that when the LLVM build uses -isystem to point to a location in the source distribution, the intended header file is not found. I think that this is mis-use of the -isystem compiler directive, and that simply -I should be used instead. To that end I have added the following gross hack to the gcc-wrap script I'm using to transform the compiler arguments as required for cross compilation, ref.:

castor: {37} diff -u ../rust190/files/gcc-wrap files/gcc-wrap
--- ../rust190/files/gcc-wrap   2025-09-20 07:18:41.413625088 +0000
+++ files/gcc-wrap      2025-11-03 13:54:59.472143568 +0000
@@ -90,7 +90,15 @@
 # (I thought this wasn't reqired, but apparently it is...)
                -isystem)
                        shift
-                       args="$args -isystem =$1"
+                       case "$1" in
+                       # Apparent mis-use of -isystem:
+                       */siphash/*)
+                               args="$args -I $1"
+                               ;;
+                       *)
+                               args="$args -isystem =$1"
+                               ;;
+                       esac
                        ;;
 # Also doctor -I directives of known paths and
 # redirect them to the --sysroot.
castor: {38} 

The failing compiler invocation ended up as

/usr/pkgsrc/wip/rust191/work/.gcc/bin/g++ -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-zrelro -fPIC -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/llvm/build/lib/Support -I/usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/src/llvm-project/llvm/lib/Support -I/usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/build/x86_64-unknown-netbsd/llvm/build/include -I/usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/src/llvm-project/llvm/include -isystem /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/src/llvm-project/llvm/../third-party/siphash/include -O2 -ffunction-sections -fdata-sections -fPIC -m64 -O2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/SipHash.cpp.o -MF CMakeFiles/LLVMSupport.dir/SipHash.cpp.o.d -o CMakeFiles/LLVMSupport.dir/SipHash.cpp.o -c /usr/pkgsrc/wip/rust191/work/rustc-1.91.0-src/src/llvm-project/llvm/lib/Support/SipHash.cpp -I/usr/pkgsrc/wip/rust191/work/.buildlink/include

With the above modification, the cross-build of rust on NetBSD/amd64 for NetBSD/earmv7hf succeeds.

Build Log

Well, I think the essence of the problem is captured above.

If really needed to narrow down the problem, I can paste the complete build log here later.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing invocation and src/llvm-project/llvm/lib/Support/SipHash.cpp, then inspect how the bundled LLVM build supplies the path src/llvm-project/llvm/../third-party/siphash/include through -isystem. Reproduce with python3.12 ./x.py dist using the shown cross-compilation configuration and verify that the NetBSD/armv7hf build succeeds without the gcc-wrap workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.