File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env rust-script
2
+ //! ```cargo
3
+ //! [dependencies]
4
+ //! libc = { version = "0.2", default-features = false }
5
+ //!
6
+ //! [profile.release]
7
+ //! strip = true
8
+ //! lto = true
9
+ //! opt-level = "s" # "z"
10
+ //! codegen-units = 1
11
+ //! panic = "abort"
12
+ //! ```
13
+
14
+ #![ no_std]
15
+ #![ no_main]
16
+
17
+ #[ panic_handler]
18
+ fn my_panic ( _info : & core:: panic:: PanicInfo ) -> ! {
19
+ loop { }
20
+ }
21
+
22
+ #[ no_mangle]
23
+ pub extern "C" fn main ( _argc : isize , _argv : * const * const u8 ) -> isize {
24
+ unsafe {
25
+ libc:: printf ( "--output--\n \0 " . as_ptr ( ) as * const _ ) ;
26
+ libc:: printf ( "hello, world\n \0 " . as_ptr ( ) as * const _ ) ;
27
+ }
28
+ 0
29
+ }
Original file line number Diff line number Diff line change @@ -260,3 +260,12 @@ fn test_same_flags() {
260
260
)
261
261
. unwrap ( )
262
262
}
263
+
264
+ #[ test]
265
+ fn test_extern_c_main ( ) {
266
+ let out = rust_script ! ( "tests/data/extern-c-main.rs" ) . unwrap ( ) ;
267
+ scan ! ( out. stdout_output( ) ;
268
+ ( "hello, world" ) => ( )
269
+ )
270
+ . unwrap ( )
271
+ }
You can’t perform that action at this time.
0 commit comments