@@ -52,7 +52,7 @@ export const toolchain = async (arg?: LLVMArg) => {
5252 sdk,
5353 source : source_ ,
5454 } = arg ?? { } ;
55- const host = host_ ?? std . triple . host ( ) ;
55+ const host = std . sdk . canonicalTriple ( host_ ?? std . triple . host ( ) ) ;
5656 const build = build_ ?? host ;
5757
5858 const sourceDir = source_ ?? source ( ) ;
@@ -69,13 +69,7 @@ export const toolchain = async (arg?: LLVMArg) => {
6969 . then ( ( d ) => d . get ( host ) )
7070 . then ( tg . Directory . expect ) ;
7171
72- const env = await std . env . arg (
73- ...deps ,
74- {
75- CFLAGS : tg . Mutation . suffix ( "-Wno-unused-command-line-argument" , " " ) ,
76- } ,
77- env_ ,
78- ) ;
72+ const env = await std . env . arg ( ...deps , env_ , { utils : false } ) ;
7973
8074 const ldsoName = glibc . interpreterName ( host ) ;
8175 // Ensure that stage2 unproxied binaries are runnable during the build, before we have a chance to wrap them post-install.
@@ -84,19 +78,18 @@ export const toolchain = async (arg?: LLVMArg) => {
8478 const stage2ExeLinkerFlags = tg `-Wl,-dynamic-linker=${ sysroot } /lib/${ ldsoName } -unwindlib=libunwind` ;
8579
8680 // Ensure that stage2 unproxied binaries are able to locate libraries during the build, without hardcoding rpaths. We'll wrap them afterwards.
87- const prepare = tg `set -x && export HOME=$PWD && export LD_LIBRARY_PATH="${ sysroot } /lib:${ zlibNgArtifact } /lib:${ ncursesArtifact } /lib:$ HOME/build/lib:$HOME/build/lib/${ host } "` ;
81+ const prepare = tg `set -x && export HOME=$PWD && export LD_LIBRARY_PATH="${ sysroot } /lib:${ zlibNgArtifact } /lib:$HOME/build/lib:$HOME/build/lib/${ host } "` ;
8882
8983 // Define default flags.
9084 const configure = {
9185 args : [
9286 tg `-DBOOTSTRAP_CMAKE_EXE_LINKER_FLAGS='${ stage2ExeLinkerFlags } '` ,
9387 tg `-DDEFAULT_SYSROOT=${ sysroot } ` ,
9488 `-DLLVM_HOST_TRIPLE=${ host } ` ,
89+ `-DTANGRAM_HOST_TRIPLE=${ host } ` ,
9590 "-DLLVM_PARALLEL_LINK_JOBS=1" ,
96- tg `-DTerminfo_ROOT=${ ncursesArtifact } ` ,
97- tg `-DBOOTSTRAP_Terminfo_ROOT=${ ncursesArtifact } ` ,
9891 tg `-DZLIB_ROOT=${ zlibNgArtifact } ` ,
99- `-DCLANG_BOOTSTRAP_PASSTHROUGH="DEFAULT_SYSROOT;LLVM_PARALLEL_LINK_JOBS;ZLIB_ROOT"` ,
92+ `-DCLANG_BOOTSTRAP_PASSTHROUGH="DEFAULT_SYSROOT;LLVM_PARALLEL_LINK_JOBS;ZLIB_ROOT;TANGRAM_HOST_TRIPLE "` ,
10093 ] ,
10194 } ;
10295
@@ -120,15 +113,22 @@ export const toolchain = async (arg?: LLVMArg) => {
120113 const phases = { prepare, configure, build : buildPhase , install } ;
121114
122115 let llvmArtifact = await cmake . build ( {
123- ...( await std . triple . rotate ( { build, host } ) ) ,
116+ host : build ,
117+ target : host ,
124118 env,
125119 phases,
126120 sdk,
127121 source : tg `${ sourceDir } /llvm` ,
128122 } ) ;
129123
130- // Add sysroot and symlinks.
124+ // Merge zlib-ng libraries into the artifact so $ORIGIN-based RPATH can find them.
125+ const zlibLibDir = await tg . Directory . expect ( zlibNgArtifact )
126+ . get ( "lib" )
127+ . then ( tg . Directory . expect ) ;
128+
129+ // Add sysroot, zlib libs, and symlinks.
131130 llvmArtifact = await tg . directory ( llvmArtifact , sysroot , {
131+ lib : zlibLibDir ,
132132 "bin/ar" : tg . symlink ( "llvm-ar" ) ,
133133 "bin/cc" : tg . symlink ( "clang" ) ,
134134 "bin/c++" : tg . symlink ( "clang++" ) ,
@@ -142,15 +142,13 @@ export const toolchain = async (arg?: LLVMArg) => {
142142 } ) ;
143143
144144 // The bootstrap compiler was not proxied. Manually wrap the output binaries.
145- // With the sysroot embedded, binaries can find libraries relative to their location.
146- // We still wrap to ensure the interpreter is correct.
145+ // With $ORIGIN-based RPATH embedded during build , binaries can find libraries
146+ // relative to their location. We still wrap to ensure the interpreter is correct.
147147
148- // Collect all required library paths.
148+ // Collect library paths for non-clang binaries that may not have RPATH set .
149149 const libDir = llvmArtifact . get ( "lib" ) . then ( tg . Directory . expect ) ;
150150 const hostLibDir = libDir . then ( ( d ) => d . get ( host ) ) . then ( tg . Directory . expect ) ;
151- const ncursesLibDir = ncursesArtifact . get ( "lib" ) . then ( tg . Directory . expect ) ;
152- const zlibLibDir = zlibNgArtifact . get ( "lib" ) . then ( tg . Directory . expect ) ;
153- const libraryPaths = [ libDir , hostLibDir , ncursesLibDir , zlibLibDir ] ;
151+ const libraryPaths = [ libDir , hostLibDir ] ;
154152
155153 // Wrap all ELF binaries in the bin directory, except clang-XX which must not be
156154 // wrapped to preserve /proc/self/exe for the -cc1 driver.
0 commit comments