Merge pull request #8429 from dcbaker/submit/rust-fix-linking-with-find-library
rust: correctly handle -l link argspull/8432/head
commit
6a9a1557e4
6 changed files with 55 additions and 2 deletions
@ -0,0 +1,24 @@ |
||||
project('rust linking to libm', 'c', 'rust') |
||||
|
||||
if host_machine.system() == 'darwin' |
||||
error('MESON_SKIP_TEST: doesnt work right on macos, please fix!') |
||||
endif |
||||
|
||||
cc = meson.get_compiler('c') |
||||
dep_m = cc.find_library('m', required : false, static : get_option('static')) |
||||
if not dep_m.found() |
||||
error('MESON_SKIP_TEST: Could not find a @0@ libm'.format(get_option('static') ? 'static' : 'shared')) |
||||
endif |
||||
|
||||
librs_math = static_library( |
||||
'rs_math', |
||||
'rs_math.rs', |
||||
dependencies : [dep_m], |
||||
) |
||||
|
||||
e = executable( |
||||
'prog', 'prog.rs', |
||||
link_with : [librs_math], |
||||
) |
||||
|
||||
test('cdepstest', e) |
@ -0,0 +1,2 @@ |
||||
option('static', type : 'boolean') |
||||
option('method', type : 'string') |
@ -0,0 +1,5 @@ |
||||
extern crate rs_math; |
||||
|
||||
fn main() { |
||||
assert_eq!(rs_math::rs_log2(8.0), 3.0); |
||||
} |
@ -0,0 +1,12 @@ |
||||
#![crate_name = "rs_math"] |
||||
|
||||
use std::os::raw::c_double; |
||||
|
||||
extern "C" { |
||||
fn log2(n: c_double) -> c_double; |
||||
} |
||||
|
||||
#[no_mangle] |
||||
pub extern fn rs_log2(n: c_double) -> c_double { |
||||
unsafe { log2(n) } |
||||
} |
@ -0,0 +1,10 @@ |
||||
{ |
||||
"matrix": { |
||||
"options": { |
||||
"static": [ |
||||
{ "val": true }, |
||||
{ "val": false } |
||||
] |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue