Statically linked rustc?


How does it possible to build rustc which is staticlly linked against both librustc_driver and libstd?

The compiler as released is already linked to libstd (I'm not familiar with librustc_driver).

@jhpratt it is linked dynamically :wink:

√ /tmp % wget
--2021-12-06 23:40:44--
Resolving ( 2600:9000:225f:dc00:5:26a9:7440:93a1, 2600:9000:225f:5400:5:26a9:7440:93a1, 2600:9000:225f:1a00:5:26a9:7440:93a1, ...
Connecting to (|2600:9000:225f:dc00:5:26a9:7440:93a1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 97498978 (93M) [application/x-tar]
Saving to: ‘rustc-1.57.0-x86_64-apple-darwin.tar.gz’

rustc-1.57.0-x86_64-apple-darwin.tar.gz       100%[==============================================================================================>]  92.98M  22.9MB/s    in 5.2s    

2021-12-06 23:40:50 (17.9 MB/s) - ‘rustc-1.57.0-x86_64-apple-darwin.tar.gz’ saved [97498978/97498978]

√ /tmp % tar xzf rustc-1.57.0-x86_64-apple-darwin.tar.gz
√ /tmp % otool -L rustc-1.57.0-x86_64-apple-darwin/rustc/bin/rustc   
	@rpath/librustc_driver-5d5e1e2505841b99.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libstd-dd8a82589e0cba34.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
√ /tmp %

as you may see rustc is dynamically linked agains both librustc_driver and libstd.

So, here I'm: how can I build rustc which is statically linked agains both librustc_driver and libstd.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.