Skip to content

Commit 60dec83

Browse files
authored
msys2 ci (#243)
* add msys2 ci job * run CI on any branch * install base-devel on msys2 * 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
1 parent 6ea5fa2 commit 60dec83

File tree

6 files changed

+39
-35
lines changed

6 files changed

+39
-35
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,51 @@ name: OpenLibm CI
22

33
on:
44
push:
5-
branches: [ master ]
65
pull_request:
76
branches: [ master ]
87

98
jobs:
10-
build:
9+
build-nix:
1110
runs-on: ${{ matrix.os }}
1211
strategy:
1312
fail-fast: false
1413
matrix:
1514
os:
1615
- ubuntu-latest
1716
- macos-latest
18-
- windows-latest
1917
arch:
2018
- x64
2119
- x86
2220
- armv7
2321
- aarch64
2422
exclude:
25-
- os: windows-latest
26-
arch: aarch64
27-
- os: windows-latest
28-
arch: armv7
29-
- os: windows-latest
30-
arch: x86
3123
- os: macos-latest
3224
arch: armv7
3325
- os: macos-latest
3426
arch: x86
3527

3628
steps:
3729
- uses: actions/checkout@v2
38-
- name: Install i686-w64-mingw32-gcc
39-
if: ${{ matrix.os == 'windows-latest' && matrix.arch == 'x86' }}
40-
shell: bash
41-
run: |
42-
choco install mingw -y --x86 --force --params "/exception:sjlj"
43-
choco install make -y
44-
echo "CC=i686-w64-mingw32-gcc" >> "${GITHUB_ENV}"
45-
- name: Set compiler for 64-bit Windows
46-
if: ${{ matrix.os == 'windows-latest' && matrix.arch == 'x64' }}
47-
shell: bash
48-
run: |
49-
echo "CC=x86_64-w64-mingw32-gcc" >> "${GITHUB_ENV}"
5030
- name: Build and run tests
5131
run: make && make test
32+
33+
build-msys2:
34+
runs-on: windows-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include:
39+
- { sys: mingw64, env: x86_64 }
40+
- { sys: mingw32, env: i686 }
41+
- { sys: ucrt64, env: ucrt-x86_64 } # Experimental!
42+
- { sys: clang64, env: clang-x86_64 } # Experimental!
43+
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: msys2/setup-msys2@v2
47+
with:
48+
msystem: ${{matrix.sys}}
49+
install: base-devel mingw-w64-${{matrix.env}}-toolchain
50+
- name: Build and run tests
51+
shell: msys2 {0}
52+
run: make && make test

Make.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ endif
9494
#keep these if statements separate
9595
ifeq ($(OS), WINNT)
9696
SHLIB_EXT = dll
97-
SONAME_FLAG = -soname
98-
CFLAGS_add += -nodefaultlibs
97+
SONAME_FLAG =
9998
shlibdir = $(bindir)
10099
else
101100
ifeq ($(OS), Darwin)

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ else
4646
OLM_MAJOR_MINOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR).$(SOMINOR)
4747
OLM_MAJOR_SHLIB_EXT := $(SHLIB_EXT).$(SOMAJOR)
4848
endif
49+
LDFLAGS_add += -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
4950
endif
5051

5152
.PHONY: all check test clean distclean \
@@ -67,7 +68,7 @@ libopenlibm.a: $(OBJS)
6768
$(AR) -rcs libopenlibm.a $(OBJS)
6869

6970
libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT): $(OBJS)
70-
$(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -Wl,$(SONAME_FLAG),libopenlibm.$(OLM_MAJOR_SHLIB_EXT) -o $@
71+
$(CC) -shared $(OBJS) $(LDFLAGS) $(LDFLAGS_add) -o $@
7172
ifneq ($(OS),WINNT)
7273
ln -sf $@ libopenlibm.$(OLM_MAJOR_SHLIB_EXT)
7374
ln -sf $@ libopenlibm.$(SHLIB_EXT)

include/openlibm_fenv_i387.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#ifndef _FENV_H_
3030
#define _FENV_H_
3131

32+
#include "openlibm_defs.h"
3233
#include "cdefs-compat.h"
3334
#include "types-compat.h"
3435

@@ -88,8 +89,8 @@ __BEGIN_DECLS
8889

8990
/* After testing for SSE support once, we cache the result in __has_sse. */
9091
enum __sse_support { __SSE_YES, __SSE_NO, __SSE_UNK };
91-
extern enum __sse_support __has_sse;
92-
int __test_sse(void);
92+
OLM_DLLEXPORT extern enum __sse_support __has_sse;
93+
OLM_DLLEXPORT int __test_sse(void);
9394
#ifdef __SSE__
9495
#define __HAS_SSE() 1
9596
#else
@@ -98,7 +99,7 @@ int __test_sse(void);
9899
#endif
99100

100101
/* Default floating-point environment */
101-
extern const fenv_t __fe_dfl_env;
102+
OLM_DLLEXPORT extern const fenv_t __fe_dfl_env;
102103
#define FE_DFL_ENV (&__fe_dfl_env)
103104

104105
#define __fldcw(__cw) __asm __volatile("fldcw %0" : : "m" (__cw))
@@ -150,8 +151,8 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
150151
return (0);
151152
}
152153

153-
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
154-
int feraiseexcept(int __excepts);
154+
OLM_DLLEXPORT int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
155+
OLM_DLLEXPORT int feraiseexcept(int __excepts);
155156

156157
__fenv_static inline int
157158
fetestexcept(int __excepts)
@@ -206,8 +207,8 @@ fesetround(int __round)
206207
return (0);
207208
}
208209

209-
int fegetenv(fenv_t *__envp);
210-
int feholdexcept(fenv_t *__envp);
210+
OLM_DLLEXPORT int fegetenv(fenv_t *__envp);
211+
OLM_DLLEXPORT int feholdexcept(fenv_t *__envp);
211212

212213
__fenv_static inline int
213214
fesetenv(const fenv_t *__envp)
@@ -231,12 +232,12 @@ fesetenv(const fenv_t *__envp)
231232
return (0);
232233
}
233234

234-
int feupdateenv(const fenv_t *__envp);
235+
OLM_DLLEXPORT int feupdateenv(const fenv_t *__envp);
235236

236237
#if __BSD_VISIBLE
237238

238-
int feenableexcept(int __mask);
239-
int fedisableexcept(int __mask);
239+
OLM_DLLEXPORT int feenableexcept(int __mask);
240+
OLM_DLLEXPORT int fedisableexcept(int __mask);
240241

241242
/* We currently provide no external definition of fegetexcept(). */
242243
static inline int

include/openlibm_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ extern const union __nan_un {
174174
#define MAXFLOAT ((float)3.40282346638528860e+38)
175175

176176
#ifndef OPENLIBM_ONLY_THREAD_SAFE
177-
extern int signgam;
177+
OLM_DLLEXPORT extern int signgam;
178178
#endif
179179
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
180180

test/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ifneq ($(OS),WINNT)
77
ifneq ($(OS),Darwin)
88
OPENLIBM_LIB += -Wl,-rpath=$(OPENLIBM_HOME)
99
endif
10+
else # WINNT
11+
CFLAGS_add += -DIMPORT_EXPORTS
1012
endif
1113

1214
all: test-double test-float # test-double-system test-float-system

0 commit comments

Comments
 (0)