Merge pull request #8429 from dcbaker/submit/rust-fix-linking-with-find-library
rust: correctly handle -l link args
This commit is contained in:
commit
6a9a1557e4
|
@ -1624,8 +1624,8 @@ int dummy;
|
|||
elif a.startswith('-L'):
|
||||
args.append(a)
|
||||
elif a.startswith('-l'):
|
||||
# This should always be a static lib, I think
|
||||
args.extend(['-l', f'static={a[2:]}'])
|
||||
_type = 'static' if e.static else 'dylib'
|
||||
args.extend(['-l', f'{_type}={a[2:]}'])
|
||||
for d in linkdirs:
|
||||
if d == '':
|
||||
d = '.'
|
||||
|
|
|
@ -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