pyodide/CLAPACK/patches/0001-Awful-hacks-for-WebAss...

284 lines
8.9 KiB
Diff

From a8b2d56cc6ff0a7d151cc9f6ef95a2cce9ca5f91 Mon Sep 17 00:00:00 2001
From: Adrian Bauer <agbauer@gmail.com>
Date: Tue, 19 Sep 2017 13:30:49 -0700
Subject: [PATCH 1/3] Awful hacks for WebAssembly build
---
BLAS/SRC/Makefile | 3 +-
BLAS/SRC/xerbla.c | 2 +
BLAS/WRAP/Makefile | 9 ++---
F2CLIBS/libf2c/Makefile | 25 ++++++-------
F2CLIBS/libf2c/arith.h | 0
Makefile | 10 ++---
SRC/Makefile | 3 +-
make.inc | 81 +++++++++++++++++++++++++++++++++++++++++
9 files changed, 109 insertions(+), 28 deletions(-)
create mode 100644 .gitignore
create mode 100644 F2CLIBS/libf2c/arith.h
create mode 100644 make.inc
diff --git a/BLAS/SRC/Makefile b/BLAS/SRC/Makefile
index 4835fd2..4a37c41 100644
--- a/BLAS/SRC/Makefile
+++ b/BLAS/SRC/Makefile
@@ -139,8 +139,7 @@ ALLOBJ=$(SBLAS1) $(SBLAS2) $(SBLAS3) $(DBLAS1) $(DBLAS2) $(DBLAS3) \
$(ZBLAS2) $(ZBLAS3) $(ALLBLAS)
$(BLASLIB): $(ALLOBJ)
- $(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
- $(RANLIB) $@
+ $(LD) -o $@ $(ALLOBJ)
single: $(SBLAS1) $(ALLBLAS) $(SBLAS2) $(SBLAS3)
$(ARCH) $(ARCHFLAGS) $(BLASLIB) $(SBLAS1) $(ALLBLAS) \
diff --git a/BLAS/SRC/xerbla.c b/BLAS/SRC/xerbla.c
index 2d7baf5..da1d7fd 100644
--- a/BLAS/SRC/xerbla.c
+++ b/BLAS/SRC/xerbla.c
@@ -10,6 +10,8 @@
http://www.netlib.org/f2c/libf2c.zip
*/
+#include <stdio.h>
+
#include "f2c.h"
#include "blaswrap.h"
diff --git a/BLAS/WRAP/Makefile b/BLAS/WRAP/Makefile
index d13fc97..16336da 100644
--- a/BLAS/WRAP/Makefile
+++ b/BLAS/WRAP/Makefile
@@ -5,12 +5,11 @@ include $(TOPDIR)/make.inc
# This is the makefile to create a wrapper for the CBLAS.
#######################################################################
-all: libcblaswr.a
+all: libcblaswr.bc
+
+libcblaswr.bc: cblaswr.o
+ $(LD) $(LDFLAGS) -o $@ $?
-libcblaswr.a: cblaswr.o
- $(ARCH) $(ARCHFLAGS) libcblaswr.a cblaswr.o
- $(RANLIB) libcblaswr.a
-
libfblaswr.a: fblaswr.o
$(ARCH) $(ARCHFLAGS) libfblaswr.a fblaswr.o
$(RANLIB) libfblaswr.a
diff --git a/F2CLIBS/libf2c/Makefile b/F2CLIBS/libf2c/Makefile
index 57eff0d..d9a42da 100644
--- a/F2CLIBS/libf2c/Makefile
+++ b/F2CLIBS/libf2c/Makefile
@@ -20,14 +20,13 @@ include $(TOPDIR)/make.inc
# compile, then strip unnecessary symbols
.c.o:
$(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c
- ld -r -x -o $*.xxx $*.o
- mv $*.xxx $*.o
+
## Under Solaris (and other systems that do not understand ld -x),
## omit -x in the ld line above.
## If your system does not have the ld command, comment out
## or remove both the ld and mv lines above.
-MISC = f77vers.o i77vers.o main.o s_rnge.o abort_.o exit_.o getarg_.o iargc_.o\
+MISC = f77vers.o i77vers.o s_rnge.o abort_.o exit_.o getarg_.o iargc_.o\
getenv_.o signal_.o s_stop.o s_paus.o system_.o cabs.o ctype.o\
derf_.o derfc_.o erf_.o erfc_.o sig_die.o uninit.o
POW = pow_ci.o pow_dd.o pow_di.o pow_hh.o pow_ii.o pow_ri.o pow_zi.o pow_zz.o
@@ -69,11 +68,10 @@ TIME = dtime_.o etime_.o
OFILES = $(MISC) $(POW) $(CX) $(DCX) $(REAL) $(DBL) $(INT) \
$(HALF) $(CMP) $(EFL) $(CHAR) $(I77) $(TIME)
-all: f2c.h signal1.h sysdep1.h libf2c.a clapack_install
+all: f2c.h signal1.h sysdep1.h libf2c.bc clapack_install
-libf2c.a: $(OFILES)
- ar r libf2c.a $?
- -ranlib libf2c.a
+libf2c.bc: $(OFILES)
+ $(LD) $(LDFLAGS) -o libf2c.bc $?
## Shared-library variant: the following rule works on Linux
## systems. Details are system-dependent. Under Linux, -fPIC
@@ -82,7 +80,7 @@ libf2c.a: $(OFILES)
## of "cc -shared".
libf2c.so: $(OFILES)
- cc -shared -o libf2c.so $(OFILES)
+ $(LD) $(LDFLAGS) -shared -o libf2c.so $(OFILES)
### If your system lacks ranlib, you don't need it; see README.
@@ -117,15 +115,14 @@ sysdep1.h: sysdep1.h0
#main.o: main.c
# $(CC) -c -Donexit=on_exit -DSkip_f2c_Undefs main.c
-install: libf2c.a
- cp libf2c.a $(LIBDIR)
- -ranlib $(LIBDIR)/libf2c.a
+install: libf2c.bc
+ cp libf2c.bc $(LIBDIR)
-clapack_install: libf2c.a
- mv libf2c.a ..
+clapack_install: libf2c.bc
+ mv libf2c.bc ..
clean:
- rm -f libf2c.a *.o arith.h signal1.h sysdep1.h
+ rm -f libf2c.bc *.o arith.h signal1.h sysdep1.h
backspac.o: fio.h
close.o: fio.h
diff --git a/F2CLIBS/libf2c/arith.h b/F2CLIBS/libf2c/arith.h
new file mode 100644
index 0000000..e69de29
diff --git a/Makefile b/Makefile
index 2875fbc..f3598b7 100644
--- a/Makefile
+++ b/Makefile
@@ -6,12 +6,12 @@
include make.inc
-all: f2clib lapack_install lib lapack_testing blas_testing
+all: f2clib cblaswrap lib
#all: f2clib lapack_install lib lapack_testing blas_testing variants_testing
#lib: lapacklib tmglib
#lib: f2clib lapacklib tmglib
-lib: f2clib blaslib variants lapacklib tmglib
+lib: f2clib blaslib lapacklib
clean: cleanlib cleantesting cleanblas_testing
@@ -23,12 +23,12 @@ blaslib:
( cd BLAS/SRC; $(MAKE) )
cblaswrap:
- ( cd BLAS/WRAP; $(MAKE) libcblaswr.a; cp libcblaswr.a ../.. )
+ ( cd BLAS/WRAP; $(MAKE) libcblaswr.bc; cp libcblaswr.bc ../.. )
fblaswrap:
( cd BLAS/WRAP; $(MAKE) libfblaswr.a; cp libfblaswr.a ../.. )
-lapacklib: lapack_install
+lapacklib:
( cd SRC; $(MAKE) )
variants:
@@ -56,7 +56,7 @@ variants_testing: lib
mv stest.out stest_lurec.out ; mv dtest.out dtest_lurec.out ; mv ctest.out ctest_lurec.out ; mv ztest.out ztest_lurec.out )
( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/qrll.a' ; \
mv stest.out stest_qrll.out ; mv dtest.out dtest_qrll.out ; mv ctest.out ctest_qrll.out ; mv ztest.out ztest_qrll.out )
-
+
blas_testing:
( cd BLAS/TESTING; $(MAKE) -f Makeblat1 )
( cd BLAS; ./xblat1s > sblat1.out ; \
diff --git a/SRC/Makefile b/SRC/Makefile
index 223f4da..9df3e92 100644
--- a/SRC/Makefile
+++ b/SRC/Makefile
@@ -369,8 +369,7 @@ ALLOBJ=$(SLASRC) $(DLASRC) $(CLASRC) $(ZLASRC) $(SCLAUX) $(DZLAUX) \
$(ALLAUX)
../$(LAPACKLIB): $(ALLOBJ) $(ALLXOBJ)
- $(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ) $(ALLXOBJ)
- $(RANLIB) $@
+ $(CC) -o $@ $(ALLOBJ) $(ALLXOBJ)
single: $(SLASRC) $(ALLAUX) $(SCLAUX)
$(ARCH) $(ARCHFLAGS) ../$(LAPACKLIB) $(SLASRC) $(ALLAUX) \
diff --git a/make.inc b/make.inc
new file mode 100644
index 0000000..7ba8d43
--- /dev/null
+++ b/make.inc
@@ -0,0 +1,81 @@
+# -*- Makefile -*-
+####################################################################
+# LAPACK make include file. #
+# LAPACK, Version 3.2.1 #
+# June 2009 #
+####################################################################
+#
+# See the INSTALL/ directory for more examples.
+#
+SHELL = /bin/sh
+#
+# The machine (platform) identifier to append to the library names
+#
+# WA for WebAssembly
+PLAT = _WA
+#
+# Modify the FORTRAN and OPTS definitions to refer to the
+# compiler and desired compiler options for your machine. NOOPT
+# refers to the compiler options desired when NO OPTIMIZATION is
+# selected. Define LOADER and LOADOPTS to refer to the loader
+# and desired load options for your machine.
+#
+#######################################################
+# This is used to compile C libary
+#CC = gcc # inherit $CC from emmake
+# if no wrapping of the blas library is needed, uncomment next line
+#CC = gcc -DNO_BLAS_WRAP
+CFLAGS = -O3 -I$(TOPDIR)/INCLUDE
+LDFLAGS = -O3
+LOADER = $(CC)
+LOADOPTS =
+NOOPT = -O0 -I$(TOPDIR)/INCLUDE
+DRVCFLAGS = $(CFLAGS)
+F2CCFLAGS = $(CFLAGS)
+#######################################################################
+
+#
+# Timer for the SECOND and DSECND routines
+#
+# Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME
+# TIMER = EXT_ETIME
+# For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
+# TIMER = EXT_ETIME_
+# For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
+# TIMER = INT_ETIME
+# If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
+# SECOND and DSECND will use a call to the Fortran standard INTERNAL FUNCTION CPU_TIME
+TIMER = INT_CPU_TIME
+# If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
+# TIMER = NONE
+#
+# The archiver and the flag(s) to use when building archive (library)
+# If you system has no ranlib, set RANLIB = echo.
+#
+ARCH = ar
+ARCHFLAGS= cr
+RANLIB = ranlib
+#
+# The location of BLAS library for linking the testing programs.
+# The target's machine-specific, optimized BLAS library should be
+# used whenever possible.
+#
+BLASLIB = ../../blas$(PLAT).bc
+#
+# Location of the extended-precision BLAS (XBLAS) Fortran library
+# used for building and testing extended-precision routines. The
+# relevant routines will be compiled and XBLAS will be linked only if
+# USEXBLAS is defined.
+#
+# USEXBLAS = Yes
+XBLASLIB =
+# XBLASLIB = -lxblas
+#
+# Names of generated libraries.
+#
+LAPACKLIB = lapack$(PLAT).bc
+F2CLIB = ../../F2CLIBS/libf2c.bc
+TMGLIB = tmglib$(PLAT).bc
+EIGSRCLIB = eigsrc$(PLAT).bc
+LINSRCLIB = linsrc$(PLAT).bc
+F2CLIB = ../../F2CLIBS/libf2c.bc
--
2.19.0