From 97cd4b8aee94b6e58c20f0d69af8cf09c83ef54f Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:48:25 +0200 Subject: [PATCH 1/7] illumos fixes to memory.c --- driver/others/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index ba3dc8a23..a7762090f 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -142,7 +142,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(_MSC_VER) && !defined(__clang__) #define CONSTRUCTOR __cdecl #define DESTRUCTOR __cdecl -#elif defined(OS_DARWIN) && defined(C_GCC) +#elif (defined(OS_DARWIN) || defined(OS_SUNOS)) && defined(C_GCC) #define CONSTRUCTOR __attribute__ ((constructor)) #define DESTRUCTOR __attribute__ ((destructor)) #else @@ -167,7 +167,7 @@ void goto_set_num_threads(int num_threads) {}; #else -#ifdef OS_LINUX +#if defined(OS_LINUX) || defined(OS_SUNOS) #ifndef NO_AFFINITY int get_num_procs(void); #else From 8635d425c17498266e7ef6c0c518b1011d4c656d Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:48:50 +0200 Subject: [PATCH 2/7] make parallel make work on illumos --- getarch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getarch.c b/getarch.c index 0a49fd1b3..ea6edbf8a 100644 --- a/getarch.c +++ b/getarch.c @@ -86,7 +86,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #endif -#ifdef linux +#if defined(linux) || defined(__sun__) #include #include #endif @@ -892,7 +892,7 @@ static int get_num_cores(void) { size_t len; #endif -#ifdef linux +#if defined(linux) || defined(__sun__) //returns the number of processors which are currently online return sysconf(_SC_NPROCESSORS_ONLN); From e737e32fd10ee77556648a4f05aaaddad30f0087 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:49:17 +0200 Subject: [PATCH 3/7] RLIMIT_NPROC doesn't exist on illumos --- driver/others/blas_server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/driver/others/blas_server.c b/driver/others/blas_server.c index e1c644a80..c3bf80173 100644 --- a/driver/others/blas_server.c +++ b/driver/others/blas_server.c @@ -70,7 +70,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*********************************************************************/ #include "common.h" -#if defined(OS_LINUX) || defined(OS_NETBSD) || defined(OS_DARWIN) || defined(OS_ANDROID) +#if defined(OS_LINUX) || defined(OS_NETBSD) || defined(OS_DARWIN) || defined(OS_ANDROID) || defined(OS_SUNOS) #include #include #include @@ -576,10 +576,12 @@ int blas_thread_init(void){ struct rlimit rlim; const char *msg = strerror(ret); fprintf(STDERR, "OpenBLAS blas_thread_init: pthread_create: %s\n", msg); +#ifdef RLIMIT_NPROC if(0 == getrlimit(RLIMIT_NPROC, &rlim)) { fprintf(STDERR, "OpenBLAS blas_thread_init: RLIMIT_NPROC " "%ld current, %ld max\n", (long)(rlim.rlim_cur), (long)(rlim.rlim_max)); } +#endif if(0 != raise(SIGINT)) { fprintf(STDERR, "OpenBLAS blas_thread_init: calling exit(3)\n"); exit(EXIT_FAILURE); From 31aff441cea3f82694a07d4461c05e5ab1e978ed Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:50:53 +0200 Subject: [PATCH 4/7] use $(AWK) in Makefile.install and switch it to nawk --- Makefile.install | 2 +- Makefile.system | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.install b/Makefile.install index 9814302b0..25783e3be 100644 --- a/Makefile.install +++ b/Makefile.install @@ -29,7 +29,7 @@ install : lib.grd #for inc @echo \#ifndef OPENBLAS_CONFIG_H > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h @echo \#define OPENBLAS_CONFIG_H >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h - @awk 'NF {print $$1, "OPENBLAS_"$$2, $$3}' config_last.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h + @$(AWK) 'NF {print $$1, "OPENBLAS_"$$2, $$3}' config_last.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h @echo \#define OPENBLAS_VERSION \" OpenBLAS $(VERSION) \" >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h @cat openblas_config_template.h >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h @echo \#endif \/\* OPENBLAS_CONFIG_H \*\/ >> $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/openblas_config.h diff --git a/Makefile.system b/Makefile.system index 42ad49849..44e6be20f 100644 --- a/Makefile.system +++ b/Makefile.system @@ -962,7 +962,7 @@ ifndef MD5SUM MD5SUM = md5sum endif -AWK = awk +AWK = nawk REVISION = -r$(VERSION) MAJOR_VERSION = $(word 1,$(subst ., ,$(VERSION))) From 7ba1d9b9ca6958f1ad5f57d5ff57f1615d97dd5a Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:50:29 +0200 Subject: [PATCH 5/7] actually build the shared lib on illumos --- Makefile | 2 +- exports/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6ad87d802..35e01a748 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ endif shared : ifndef NO_SHARED -ifeq ($(OSNAME), Linux) +ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) @$(MAKE) -C exports so @-ln -fs $(LIBSONAME) $(LIBPREFIX).so @-ln -fs $(LIBSONAME) $(LIBPREFIX).so.$(MAJOR_VERSION) diff --git a/exports/Makefile b/exports/Makefile index 177e975ea..2b3cdc476 100644 --- a/exports/Makefile +++ b/exports/Makefile @@ -110,7 +110,7 @@ endif dllinit.$(SUFFIX) : dllinit.c $(CC) $(CFLAGS) -c -o $(@F) -s $< -ifeq ($(OSNAME), Linux) +ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) so : ../$(LIBSONAME) From 8d85be770dc31d9d310961f557cb3ce3d80d571c Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:50:05 +0200 Subject: [PATCH 6/7] actually install the shared lib on illumos --- Makefile.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.install b/Makefile.install index 25783e3be..edcfe89a2 100644 --- a/Makefile.install +++ b/Makefile.install @@ -64,7 +64,7 @@ endif #for install shared library ifndef NO_SHARED @echo Copying the shared library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) -ifeq ($(OSNAME), Linux) +ifeq ($(OSNAME), $(filter $(OSNAME),Linux SunOS)) @install -pm755 $(LIBSONAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \ ln -fs $(LIBSONAME) $(LIBPREFIX).so ; \ From d6afac962488157844345abe58e0352fa46f06b4 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Fri, 22 Jan 2016 18:46:27 +0200 Subject: [PATCH 7/7] don't pass -Y at all to the linker on illumos the illumos linker can't understand the "-Y/lib"... form that f_check generates, and -Wl cannot pass options that include commas --- f_check | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/f_check b/f_check index e7e46886f..4c9d81e9f 100644 --- a/f_check +++ b/f_check @@ -1,5 +1,7 @@ #!/usr/bin/perl +$hostos = `uname -s | sed -e s/\-.*//`; chop($hostos); + # # 1. Not specified # 1.1 Automatically detect, then check compiler @@ -272,8 +274,9 @@ if ($link ne "") { } if ($flags =~ /^\-Y/) { + next if ($hostos eq 'SunOS'); $linker_L .= "-Wl,". $flags . " "; - } + } if ($flags =~ /^\-rpath\@/) { $flags =~ s/\@/\,/g;