Skip to content

Commit

Permalink
Merge pull request #3 from imeka/personal/fmorency/fix-armv7
Browse files Browse the repository at this point in the history
Fix for ARMv7 (rpi)
  • Loading branch information
noshu committed Jul 30, 2019
2 parents d3b520d + 1ceae32 commit ed4451d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
@@ -1,7 +1,8 @@
[package]
name = "lbfgsb-sys"
version = "0.1.0"
authors = ["noshu <naushad1290@gmail.com>"]
version = "0.1.1"
authors = ["noshu <naushad1290@gmail.com>",
"Felix C. Morency <felix.morency@imeka.ca>"]
license= "MIT/BSD-3-Clause"
description = "The package provides an interface to L-BFGS-B fortran routine"
homepage = "https://github.com/noshu/lbfgsb-sys"
Expand All @@ -10,4 +11,4 @@ build = "build.rs"
[features]
static = []
[dependencies]
libc = "0.2.11"
libc = "0.2.11"
34 changes: 28 additions & 6 deletions build.rs
Expand Up @@ -19,16 +19,38 @@ fn main() {
let os = if cfg!(target_os = "macos"){"Macos"}
else if cfg!(target_os = "windows"){"Windows"}
else {"Linux"};
let com = if os=="Windows" {"mingw32-make"}else{"make"};
run(Command::new(com)
let make_cmd = if os == "Windows" { "mingw32-make" } else { "make" };
run(Command::new(make_cmd)
.arg(kind)
.arg(format!("OUTPUT={}",output.display()))
.arg(format!("OSNAME={}",os))
.arg(format!("OUTPUT={}", output.display()))
.arg(format!("OSNAME={}", os))
.current_dir(&source));

println!("cargo:rustc-link-search={}", output.display());
println!("cargo:rustc-link-lib={}=lbfgs",kind);
println!("cargo:rustc-link-lib=dylib=gfortran");
println!("cargo:rustc-link-lib={}=lbfgs", kind);
println!("cargo:rustc-link-lib=dylib=gcc");

let target = variable!("TARGET");
let mut fc_lib_type = "dylib";
if target == "x86_64-apple-darwin" || target == "x86_64-pc-windows-gnu" {
fc_lib_type = "static";

// Poke $FC$ for static lib folder
let fc_out = Command::new(variable!("FC"))
.arg("-print-file-name=libgfortran.a")
.output()
.expect("Failed to find libgfortran.a");
let fc_stdout = String::from_utf8(fc_out.stdout).expect("Invalid path to libgfortran.a");
let fc_lib_cwd = PathBuf::from(fc_stdout.to_string());
let fc_lib_pwd = fc_lib_cwd.parent().expect("Path to libgfortran.a not found");
println!("cargo:rustc-link-search={}", fc_lib_pwd.to_str().unwrap());
}

println!("cargo:rustc-link-lib={}=gfortran", fc_lib_type);

if target == "x86_64-apple-darwin" {
println!("cargo:rustc-link-lib={}=quadmath", fc_lib_type);
}
}
fn run(command: &mut Command) {
println!("Running: {:?}", command);
Expand Down
6 changes: 2 additions & 4 deletions fortran/Makefile
@@ -1,5 +1,3 @@
FC = gfortran
AR = ar
AFLAG = crus
SFlAG = -shared -o
FFLAGS = -O3 -Wall -fexceptions -g -Wno-uninitialized -c -fPIC -o
Expand All @@ -8,7 +6,7 @@ LINPACK = linpack.f
BLAS = blas.f
TIMER = timer.f
STRING = string.f
static :
static :
@echo "static linking selected"
@echo "Compiling"
$(FC) $(LBFGSB) $(FFLAGS) $(OUTPUT)/lbfgsb.o
Expand All @@ -26,7 +24,7 @@ ifeq ($(OSNAME),Windows)
$(FC) $(LINPACK) $(FFLAGS) $(OUTPUT)/linpack.o
$(FC) $(BLAS) $(FFLAGS) $(OUTPUT)/blas.o
$(FC) $(TIMER) $(FFLAGS) $(OUTPUT)/timer.o
$(FC) $(STRING) $(FFLAGS) $(OUTPUT)/string.o
$(FC) $(STRING) $(FFLAGS) $(OUTPUT)/string.o
@echo "creating static library"
$(FC) $(SFlAG) $(OUTPUT)/liblbfgs.dll $(OUTPUT)/*.o
endif
Expand Down
6 changes: 4 additions & 2 deletions fortran/lbfgsb.f
Expand Up @@ -3278,8 +3278,10 @@ subroutine subsm ( n, m, nsub, ind, l, u, nbd, x, d, xp, ws, wy,
55 continue
if ( dd_p .gt.zero ) then
call dcopy( n, xp, 1, x, 1 )
write(6,*) ' Positive dir derivative in projection '
write(6,*) ' Using the backtracking step '
if (iprint .ge. 0) then
write(6,*) ' Positive dir derivative in projection '
write(6,*) ' Using the backtracking step '
endif
else
go to 911
endif
Expand Down

0 comments on commit ed4451d

Please sign in to comment.