Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link test for LAPACK routines written in Fortran #43

Merged
merged 6 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/openblas-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
- uses: actions/checkout@v1
with:
submodules: 'recursive'
- name: Install GCC-Fortran by apt
- name: Install gfortran by apt
run: |
apt update
apt install -y gfortran
Expand Down
15 changes: 14 additions & 1 deletion openblas-src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,20 @@ fn build() {
} else {
cfg.no_static = true;
}
cfg.build(&output).unwrap();
let deliv = cfg.build(&output).unwrap();

for search_path in &deliv.make_conf.c_extra_libs.search_paths {
println!("cargo:rustc-link-search={}", search_path.display());
}
for lib in &deliv.make_conf.c_extra_libs.libs {
println!("cargo:rustc-link-lib={}", lib);
}
for search_path in &deliv.make_conf.f_extra_libs.search_paths {
println!("cargo:rustc-link-search={}", search_path.display());
}
for lib in &deliv.make_conf.f_extra_libs.libs {
println!("cargo:rustc-link-lib={}", lib);
}
println!("cargo:rustc-link-search={}", output.display());
}

Expand Down
72 changes: 72 additions & 0 deletions openblas-src/tests/fortran_lapack.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// FIXME This should be test also on Windows and macOS.
//
// However, we have several problems:
//
// - we cannot build Fortran part of OpenBLAS on windows-msvc platform
// because the absence of Fortran compiler
//
// - In macOS, we can get gfortran by `brew install gcc`,
// but it is too time-consuming to execute on CI.
// GitHub Actions's macOS instance says gfotran is "installed",
// but it is too fragile me to give up using it.
//
#![cfg(target_os = "linux")]

extern crate openblas_src as _src;

extern "C" {
fn dormbr_(
vect: *const u8,
side: *const u8,
trans: *const u8,
m: *const i32,
n: *const i32,
k: *const i32,
A: *const f64,
lda: *const i32,
tau: *const f64,
C: *mut f64,
ldc: *const i32,
work: *mut f64,
lwork: *const i32,
info: *mut i32,
);
}

// `dormbr_` is imported from reference LAPACK written in Fortran into OpenBLAS project.
// This test will fail to link when OpenBLAS does not build Fortran part.
#[test]
fn test_link_lapack() {
let m = 1;
let n = 1;
let k = 1;
let vect = b'Q';
let side = b'L';
let trans = b'N';
let a = vec![0.0];
let lda = 1;
let mut c = vec![0.0];
let ldc = 1;
let tau = 0.0;
let mut work = vec![0.0];
let lwork = 1;
let mut info = 0;
unsafe {
dormbr_(
&vect,
&side,
&trans,
&m,
&n,
&k,
a.as_ptr(),
&lda,
&tau,
c.as_mut_ptr(),
&ldc,
work.as_mut_ptr(),
&lwork,
&mut info,
);
}
}