Merge pull request #9560 from jeremyd2019/openlibm-test-patch

openlibm: update with upstream patches
This commit is contained in:
Christoph Reiter
2021-09-10 08:49:20 +02:00
committed by GitHub
5 changed files with 273 additions and 41 deletions

View File

@@ -1,29 +1,62 @@
--- openlibm-0.7.2/Make.inc.orig 2020-10-22 13:21:20.340231200 +0300
+++ openlibm-0.7.2/Make.inc 2020-10-22 13:21:23.639101200 +0300
@@ -96,7 +96,7 @@
From 60dec83e3322282eeea283a1950b25fc91d39233 Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Thu, 9 Sep 2021 15:49:37 -0700
Subject: [PATCH] msys2 ci (#243)
* remove soname and nodefaultlibs flags from mingw
* avoid soname on Windows
* add OLM_DLLEXPORT to signgam
it needs to be exported from the DLL also
* define IMPORT_EXPORTS on WINNT
While there are function export thunks in the import library that allow the linker to do the right thing for functions even if this is not set, it is required for the linker to do the right thing with variables being imported from a DLL (namely, signgam)
* add OLM_DLLEXPORT to openlibm_fenv_i387.h
seems this whole header was overlooked
* Update openlibm_fenv_i387.h
include openlibm_defs.h for OLM_DLLEXPORT
---
Make.inc | 3 +--
Makefile | 3 ++-
include/openlibm_fenv_i387.h | 21 +++++++++---------
include/openlibm_math.h | 2 +-
test/Makefile | 2 ++
6 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/Make.inc b/Make.inc
index 8e443c8..3cd1ebe 100644
--- a/Make.inc
+++ b/Make.inc
@@ -94,8 +94,7 @@ endif
#keep these if statements separate
ifeq ($(OS), WINNT)
SHLIB_EXT = dll
SONAME_FLAG = -soname
-SONAME_FLAG = -soname
-CFLAGS_add += -nodefaultlibs
+#CFLAGS_add += -nodefaultlibs
+SONAME_FLAG =
shlibdir = $(bindir)
else
ifeq ($(OS), Darwin)
--- openlibm-0.7.2/Makefile.orig 2020-10-22 13:20:33.652252700 +0300
+++ openlibm-0.7.2/Makefile 2020-10-22 13:26:00.674095900 +0300
@@ -42,9 +42,11 @@
ifeq ($(OS), Darwin)
OLM_MAJOR_MINOR_SHLIB_EXT := $(SOMAJOR).$(SOMINOR).$(SHLIB_EXT)
OLM_MAJOR_SHLIB_EXT := $(SOMAJOR).$(SHLIB_EXT)
+LDFLAGS_add += -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
else
diff --git a/Makefile b/Makefile
index 865123e..7c99003 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,7 @@ else
OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR).$(SOMINOR)
OLM_MAJOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR)
+LDFLAGS_add += -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
endif
+LDFLAGS_add += -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
endif
@@ -67,7 +69,7 @@
.PHONY: all check test clean distclean \
@@ -67,7 +68,7 @@ libopenlibm.a: $(OBJS)
$(AR) -rcs libopenlibm.a $(OBJS)
libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT): $(OBJS)
@@ -32,17 +65,99 @@
ifneq ($(OS),WINNT)
ln -sf $@ libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
ln -sf $@ libopenlibm.$(SHLIB_EXT)
@@ -95,7 +97,13 @@
diff --git a/include/openlibm_fenv_i387.h b/include/openlibm_fenv_i387.h
index c3a987c..ec4eb87 100644
--- a/include/openlibm_fenv_i387.h
+++ b/include/openlibm_fenv_i387.h
@@ -29,6 +29,7 @@
#ifndef _FENV_H_
#define _FENV_H_
install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
mkdir -p $(DESTDIR)$(shlibdir)
+ifeq ($(OS), WINNT)
+ mkdir -p $(DESTDIR)$(libdir)
+ cp -RpP -f libopenlibm.*$(SHLIB_EXT) $(DESTDIR)$(shlibdir)/
+ cp -RpP -f libopenlibm.*$(SHLIB_EXT).a $(DESTDIR)$(libdir)/
+else
cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
+endif
+#include "openlibm_defs.h"
#include "cdefs-compat.h"
#include "types-compat.h"
install-pkgconfig: openlibm.pc
mkdir -p $(DESTDIR)$(pkgconfigdir)
@@ -88,8 +89,8 @@ __BEGIN_DECLS
/* After testing for SSE support once, we cache the result in __has_sse. */
enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
-extern enum __sse_support __has_sse;
-int __test_sse(void);
+OLM_DLLEXPORT extern enum __sse_support __has_sse;
+OLM_DLLEXPORT int __test_sse(void);
#ifdef __SSE__
#define __HAS_SSE() 1
#else
@@ -98,7 +99,7 @@ int __test_sse(void);
#endif
/* Default floating-point environment */
-extern const fenv_t __fe_dfl_env;
+OLM_DLLEXPORT extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
#define __fldcw(__cw) __asm __volatile("fldcw %0" : : "m" (__cw))
@@ -150,8 +151,8 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
return (0);
}
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
+OLM_DLLEXPORT int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
+OLM_DLLEXPORT int feraiseexcept(int __excepts);
__fenv_static inline int
fetestexcept(int __excepts)
@@ -206,8 +207,8 @@ fesetround(int __round)
return (0);
}
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
+OLM_DLLEXPORT int fegetenv(fenv_t *__envp);
+OLM_DLLEXPORT int feholdexcept(fenv_t *__envp);
__fenv_static inline int
fesetenv(const fenv_t *__envp)
@@ -231,12 +232,12 @@ fesetenv(const fenv_t *__envp)
return (0);
}
-int feupdateenv(const fenv_t *__envp);
+OLM_DLLEXPORT int feupdateenv(const fenv_t *__envp);
#if __BSD_VISIBLE
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
+OLM_DLLEXPORT int feenableexcept(int __mask);
+OLM_DLLEXPORT int fedisableexcept(int __mask);
/* We currently provide no external definition of fegetexcept(). */
static inline int
diff --git a/include/openlibm_math.h b/include/openlibm_math.h
index 3e510a9..701ad70 100644
--- a/include/openlibm_math.h
+++ b/include/openlibm_math.h
@@ -174,7 +174,7 @@ extern const union __nan_un {
#define MAXFLOAT ((float)3.40282346638528860e+38)
#ifndef OPENLIBM_ONLY_THREAD_SAFE
-extern int signgam;
+OLM_DLLEXPORT extern int signgam;
#endif
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
diff --git a/test/Makefile b/test/Makefile
index a7f7cb9..a61ce5a 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,6 +7,8 @@ ifneq ($(OS),WINNT)
ifneq ($(OS),Darwin)
OPENLIBM_LIB += -Wl,-rpath=$(OPENLIBM_HOME)
endif
+else # WINNT
+CFLAGS_add += -DIMPORT_EXPORTS
endif
all: test-double test-float # test-double-system test-float-system

View File

@@ -1,13 +1,38 @@
--- openlibm-0.7.5/src/cdefs-compat.h 2021-02-17 09:04:36.000000000 -0800
+++ openlibm-0.7.5/src/cdefs-compat.h 2021-08-25 17:59:51.875525300 -0700
@@ -61,8 +61,8 @@
From 2bcd30e0c88ccf2a7cbe7ec8248d64a198559fcc Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Wed, 8 Sep 2021 19:08:42 -0700
Subject: [PATCH] prefix symbols with _ for 32-bit x86 Windows
In a case that I believe can only be hit for Clang i686-*-windows-gnu (AKA MinGW), symbols in asm need to be prefixed with `_`. Fixes #237
---
src/cdefs-compat.h | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/cdefs-compat.h b/src/cdefs-compat.h
index c7deeb1..834c547 100644
--- a/src/cdefs-compat.h
+++ b/src/cdefs-compat.h
@@ -59,14 +59,19 @@
#endif /* __warn_references */
#endif /* __STDC__ */
#elif defined(__clang__) /* CLANG */
+#if defined(_WIN32) && defined(_X86_)
+#define openlibm_asm_symbol_prefix "_"
+#else
+#define openlibm_asm_symbol_prefix ""
+#endif
#ifdef __STDC__
#define openlibm_weak_reference(sym,alias) \
- __asm__(".weak_reference " #alias); \
- __asm__(".set " #alias ", " #sym)
+ __asm__(".weak_reference " __MINGW64_STRINGIFY(__MINGW_USYMBOL(alias))); \
+ __asm__(".set " __MINGW64_STRINGIFY(__MINGW_USYMBOL(alias)) ", " __MINGW64_STRINGIFY(__MINGW_USYMBOL(sym)))
+ __asm__(".weak_reference " openlibm_asm_symbol_prefix #alias); \
+ __asm__(".set " openlibm_asm_symbol_prefix #alias ", " openlibm_asm_symbol_prefix #sym)
#else
#define openlibm_weak_reference(sym,alias) \
__asm__(".weak_reference alias");\
- __asm__(".weak_reference alias");\
- __asm__(".set alias, sym")
+ __asm__(".weak_reference openlibm_asm_symbol_prefix/**/alias");\
+ __asm__(".set openlibm_asm_symbol_prefix/**/alias, openlibm_asm_symbol_prefix/**/sym")
#endif
#else /* !__ELF__ */
#ifdef __STDC__

View File

@@ -0,0 +1,28 @@
From a9568fbd227b42baa31ceca550550b7df792a6e8 Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Thu, 9 Sep 2021 21:06:52 -0700
Subject: [PATCH] [Windows] install import library to libdir (#249)
import libraries need to go in libdir (`/lib`), while dlls need to be on the PATH so need to be installed to shlibdir (`/bin`)
---
Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Makefile b/Makefile
index 7c99003..0f502a1 100644
--- a/Makefile
+++ b/Makefile
@@ -96,7 +96,13 @@ install-static: libopenlibm.a
install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
mkdir -p $(DESTDIR)$(shlibdir)
+ifeq ($(OS), WINNT)
+ mkdir -p $(DESTDIR)$(libdir)
+ cp -RpP -f libopenlibm.*$(SHLIB_EXT) $(DESTDIR)$(shlibdir)/
+ cp -RpP -f libopenlibm.*$(SHLIB_EXT).a $(DESTDIR)$(libdir)/
+else
cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
+endif
install-pkgconfig: openlibm.pc
mkdir -p $(DESTDIR)$(pkgconfigdir)

View File

@@ -0,0 +1,54 @@
From 3d4a902f316d20a6c8c26b21fedc79d564e68cab Mon Sep 17 00:00:00 2001
From: jeremyd2019 <github@jdrake.com>
Date: Thu, 9 Sep 2021 21:09:04 -0700
Subject: [PATCH] Fixes for Windows ARM64 (#251)
* aarch64_fpmath.h: deal with LLP64 (Windows ARM64)
use uint64_t instead of unsigned long, as unsigned long is only 32 bits on Windows
* Make.inc: WINNT aarch64 long double is double
Add to list along with Darwin
---
Make.inc | 2 +-
src/aarch64_fpmath.h | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Make.inc b/Make.inc
index 3cd1ebe..0c6dd3f 100644
--- a/Make.inc
+++ b/Make.inc
@@ -151,7 +151,7 @@ ifneq ($(filter $(ARCH),i387 amd64),)
# `long double` is the same as `double`.
LONG_DOUBLE_NOT_DOUBLE := 1
else ifeq ($(ARCH), aarch64)
-ifneq ($(OS),Darwin)
+ifeq ($(filter $(OS),Darwin WINNT),)
LONG_DOUBLE_NOT_DOUBLE := 1
endif
endif
diff --git a/src/aarch64_fpmath.h b/src/aarch64_fpmath.h
index c4e407c..c95ea9b 100644
--- a/src/aarch64_fpmath.h
+++ b/src/aarch64_fpmath.h
@@ -30,15 +30,15 @@
union IEEEl2bits {
long double e;
struct {
- unsigned long manl :64;
- unsigned long manh :48;
+ uint64_t manl :64;
+ uint64_t manh :48;
unsigned int exp :15;
unsigned int sign :1;
} bits;
/* TODO andrew: Check the packing here */
struct {
- unsigned long manl :64;
- unsigned long manh :48;
+ uint64_t manl :64;
+ uint64_t manh :48;
unsigned int expsign :16;
} xbits;
};

View File

@@ -4,19 +4,23 @@ _realname=openlibm
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.7.5
pkgrel=2
pkgrel=3
pkgdesc="High quality system independent, portable, open source libm implementation (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://openlibm.org'
license=('MIT')
options=('strip' 'staticlibs')
source=("${_realname}-${pkgver}.tar.gz::https://github.com/JuliaMath/${_realname}/archive/v${pkgver}.tar.gz"
01-mingw-build.patch
02-mingw-clang-symbol.patch)
02-mingw-clang-symbol.patch
03-mingw-importlib-install.patch
04-mingw-aarch64.patch)
sha256sums=('be983b9e1e40e696e8bbb7eb8f6376d3ca0ae675ae6d82936540385b0eeec15b'
'8fc88f5296a5963dc0389da656f299d7ace0a26a79882acc2596b686937a6e70'
'a81c645d04f53d228d81f2c1b250822c5fc4e8630dd593fa9dd90bc32876c198')
'ea684a10d608ffee487be0876d180c6d0124315302494fd7bc712a35885b925e'
'15891e30dad6c25e4f6b476be6ec77fab06872349bffb945afc8306a69c8dbf0'
'93a7417e899ecac7fc3fb69ccf616245679f35e7382139b664758b371beb5f22'
'd865e6246da44e2c8e15af417c188903aa14c2026d50bee902a4ba8ebe205f3d')
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
@@ -39,8 +43,14 @@ del_file_exists() {
prepare() {
cd ${srcdir}/${_realname}-${pkgver}
apply_patch_with_msg 01-mingw-build.patch \
02-mingw-clang-symbol.patch
# https://github.com/JuliaMath/openlibm/commit/60dec83e3322282eeea283a1950b25fc91d39233 (partial)
apply_patch_with_msg 01-mingw-build.patch
# https://github.com/JuliaMath/openlibm/commit/d0ef09a62d726d8a4422c8541ef0d076b26b50b5
apply_patch_with_msg 02-mingw-clang-symbol.patch
# https://github.com/JuliaMath/openlibm/commit/a9568fbd227b42baa31ceca550550b7df792a6e8
apply_patch_with_msg 03-mingw-importlib-install.patch
# https://github.com/JuliaMath/openlibm/commit/3d4a902f316d20a6c8c26b21fedc79d564e68cab
apply_patch_with_msg 04-mingw-aarch64.patch
}
build() {
@@ -58,7 +68,7 @@ build() {
check() {
cd "${srcdir}"/build-${CARCH}
make check || true
make test
}
package() {