File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Check that `no_std` binaries can link and run without depending on `libstd`.
2+
3+ //@ run-pass
4+ //@ compile-flags: -Cpanic=abort
5+ //@ ignore-wasm different `main` convention
6+
7+ #![ no_std]
8+ #![ no_main]
9+
10+ use core:: ffi:: { c_char, c_int} ;
11+ use core:: panic:: PanicInfo ;
12+
13+ // Need to link libSystem on Apple platforms, otherwise the linker fails with:
14+ // > ld: dynamic executables or dylibs must link with libSystem.dylib
15+ //
16+ // With the new linker introduced in Xcode 15, the error is instead:
17+ // > Undefined symbols: "dyld_stub_binder", referenced from: <initial-undefines>
18+ //
19+ // This _can_ be worked around by raising the deployment target with
20+ // MACOSX_DEPLOYMENT_TARGET=13.0, though it's a bit hard to test that while
21+ // still allowing the test suite to support running with older Xcode versions.
22+ #[ cfg_attr( target_vendor = "apple" , link( name = "System" ) ) ]
23+ extern "C" { }
24+
25+ #[ panic_handler]
26+ fn panic_handler ( _info : & PanicInfo < ' _ > ) -> ! {
27+ loop { }
28+ }
29+
30+ #[ no_mangle]
31+ extern "C" fn main ( _argc : c_int , _argv : * const * const c_char ) -> c_int {
32+ 0
33+ }
You can’t perform that action at this time.
0 commit comments