Skip to content

Commit eab1bf9

Browse files
committed
Use Nicolas' modernisation of fdlibm to provide cross-platform bit-identical
floating-point (CPBIFP) in the standard VM, no longer being dependent on FloatMathPlugin, and hence not having to change image-level primitive definitions to access CPBIFP. This is work in progress, but does not disturb normal builds. To access this code you must define BIT_IDENTICAL_FLOATING_POINT in a Makefile. e.g. here is a Mac makefile: --------8<-------- BIT_IDENTICAL_FLOATING_POINT=BIT_IDENTICAL_FLOATING_POINT VMSRCDIR:= ../../spur64src/vm SOURCEFILE:=SqueakV50.sources include ../common/Makefile.app.squeak --------8<-------- and here is a Windows makefile: --------8<-------- VM:=CROQUET BIT_IDENTICAL_FLOATING_POINT:=BIT_IDENTICAL_FLOATING_POINT VMSRCDIR:=../../spur64src/vm VSCMD_ARG_HOST_ARCH := $(shell echo $$VSCMD_ARG_HOST_ARCH) ifeq ($(VSCMD_ARG_HOST_ARCH),) include ../common/Makefile else include ../common/Makefile.msvc endif --------8<-------- Nothing has been done for linux yet, but it will soon; I have investment in the Pi 4. The strategy is as follows: Nicolas' updated fdlibm code is included in platforms/Cross/third-party/fdlibm. This code is built into a libm.a by each build alongside its internal plugin .libs, and linked into the main VM, iff the Makefile defines BIT_IDENTICAL_FLOATING_POINT. [Nothing has yet been done for external plugins. We either need to construct a shared library/dll for libm for these, or link it statically as per the main VM.] Since sq.h includes <math.h> it now also includes sqMathShim.h. If BIT_IDENTICAL_FLOATING_POINT is defined as non-zero on the compiler command line, sqMathShim.h pulls in fdlibm.h and redefines all relevant math functions to __ieee754 duals, e.g. # define acos __ieee754_acos. If BIT_IDENTICAL_FLOATING_POINT is not so defined sqMathShim.h does nothing. Hence, unless BIT_IDENTICAL_FLOATING_POINT is not defined in the Makefile the VM builds as before.
1 parent 749c652 commit eab1bf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+11855
-11
lines changed

build.macos64x64/common/Makefile.flags

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ print-sdks:
2424
# N.B. ARC isn't supported by the os-x 32-bit legacy Objective-C runtime kernel.
2525
# ARC is supported only on 64-bits, and then only for the 10.7 SDK and later.
2626
OBJC_CODE_MODEL := -fobjc-arc
27+
ifdef BIT_IDENTICAL_FLOATING_POINT
28+
CFLAGS:=$(CFLAGS) -DBIT_IDENTICAL_FLOATING_POINT=1
29+
endif
2730
CFLAGS:=$(CFLAGS) -DBUILD_FOR_OSX=1 -DUSE_METAL=1 -DUSE_OPENGL=1 -DUSE_CORE_GRAPHICS=1 \
2831
-arch $(TARGET_ARCH) \
2932
-mmacosx-version-min=$(TARGET_VERSION_MIN) -msse4.2 \

build.macos64x64/common/Makefile.vm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ OBJDIR:= $(BLDDIR)/vm
4444

4545
PLATDIR:=../../platforms
4646
CROSSDIR:=$(PLATDIR)/Cross/vm
47+
TPDIR:=$(PLATDIR)/Cross/third-party
4748
OSXDIR:=$(PLATDIR)/iOS/vm/OSX
4849
OSXCOMMONDIR:=$(PLATDIR)/iOS/vm/Common
4950
OSXCLASSESDIR:=$(PLATDIR)/iOS/vm/Common/Classes
@@ -88,6 +89,10 @@ include plugins.ext
8889
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
8990
BUNDLES:= $(addprefix $(OBJDIR)/, $(addsuffix .bundle, $(EXTERNAL_PLUGINS)))
9091

92+
ifdef BIT_IDENTICAL_FLOATING_POINT
93+
LIBS:=$(BLDDIR)/fdlibm/libm.a $(LIBS)
94+
endif
95+
9196
# VM config flags.
9297
ifeq ($(CONFIGURATION),debug)
9398
OFLAGS:= -g -O0 -fno-omit-frame-pointer
@@ -300,6 +305,11 @@ $(OBJDIR)/%.dylib: FORCE
300305
#%.bundle: $(OBJDIR)/%.bundle
301306
# make $(MAKEFLAGS) $<
302307

308+
$(BLDDIR)/fdlibm/libm.a:
309+
@-mkdir -p $(@D)
310+
$(MAKE) CFLAGS="$(OFLAGS) -D_IEEE_LIBM -isysroot $(SDK)" -C $(@D) \
311+
TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote
312+
303313
FORCE:
304314

305315
.PRECIOUS: $(OBJDIR)/%.lib $(OBJDIR)/%.bundle

build.win64x64/common/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ OBJDIR:= $(BUILD)/vm
4949

5050
PLATDIR:=../../platforms
5151
CROSSDIR:=$(PLATDIR)/Cross/vm
52+
TPDIR:=$(PLATDIR)/Cross/third-party
5253
WIN32DIR:=$(PLATDIR)/win32/vm
5354
WIN32PLUGINSDIR:=$(PLATDIR)/win32/plugins
5455
WIN32MISCDIR:=$(PLATDIR)/win32/misc
@@ -74,6 +75,10 @@ include plugins.int
7475
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
7576
DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS)))
7677

78+
ifdef BIT_IDENTICAL_FLOATING_POINT
79+
LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS)
80+
endif
81+
7782
#############################################################################
7883
# The third-party libraries
7984
#
@@ -284,6 +289,12 @@ $(OBJDIR)/%.dll: $(call plugin-makefile,$(*F))
284289
THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \
285290
COGDEFS="$(COGDEFS)" LIBNAME=$(*F) $(OBJDIR)/$(*F).dll
286291

292+
$(BUILD)/fdlibm/libm.a:
293+
@-mkdir -p $(@D)
294+
$(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \
295+
TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote
296+
297+
287298
#############################################################################
288299
# Basic rules
289300
#

build.win64x64/common/Makefile.msvc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ OBJDIR:= $(BUILD)/vm
5151

5252
PLATDIR:=../../platforms
5353
CROSSDIR:=$(PLATDIR)/Cross/vm
54+
TPDIR:=$(PLATDIR)/Cross/third-party
5455
WIN32DIR:=$(PLATDIR)/win32/vm
5556
WIN32PLUGINSDIR:=$(PLATDIR)/win32/plugins
5657
WIN32MISCDIR:=$(PLATDIR)/win32/misc
@@ -85,6 +86,10 @@ include plugins.int
8586
LIBS:= $(addprefix $(OBJDIR)/, $(addsuffix .lib, $(INTERNAL_PLUGINS)))
8687
DLLS:= $(addprefix $(OBJDIR)/, $(addsuffix .dll, $(EXTERNAL_PLUGINS)))
8788

89+
ifdef BIT_IDENTICAL_FLOATING_POINT
90+
LIBS:=$(BUILD)/fdlibm/libm.a $(LIBS)
91+
endif
92+
8893
#############################################################################
8994
# The third-party libraries
9095
#
@@ -267,6 +272,12 @@ $(OBJDIR)/%.dll: $(call plugin-makefile,$(*F))
267272
THIRDPARTYOUTDIR=$(THIRDPARTYOUTDIR) \
268273
COGDEFS="$(COGDEFS)" LIBNAME=$(*F) VMLIB=$(VMLIB) $(OBJDIR)/$(*F).dll
269274

275+
$(BUILD)/fdlibm/libm.a:
276+
@-mkdir -p $(@D)
277+
$(MAKE) CC='$(CC)' CFLAGS="$(CFLAGS) -D_IEEE_LIBM" -C $(@D) \
278+
TP=../../$(TPDIR) -f ../../$(TPDIR)/fdlibm/Makefile.remote
279+
280+
270281
#############################################################################
271282
# Basic rules
272283
#

build.win64x64/common/Makefile.msvc.tools

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
4747
else
4848
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
4949
endif
50+
ifdef BIT_IDENTICAL_FLOATING_POINT
51+
COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1
52+
endif
5053

5154
# MSVC's preprocessor (bless its heart) can't manage complex expansions
5255
# and so unless we specify USE_INLINE_MEMORY_ACCESSORS lots of things

build.win64x64/common/Makefile.tools

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ COGDEFS:= $(COGDEFS) -DCOGMTVM=1 -DDEBUGVM=$(DEBUGVM)
4141
else
4242
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
4343
endif
44+
ifdef BIT_IDENTICAL_FLOATING_POINT
45+
COGDEFS:= $(COGDEFS) -DBIT_IDENTICAL_FLOATING_POINT=1
46+
endif
4447

4548
# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h)
4649
WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#
2+
# @(#)Makefile 1.4 95/01/18
3+
#
4+
# ====================================================
5+
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6+
#
7+
# Developed at SunSoft, a Sun Microsystems, Inc. business.
8+
# Permission to use, copy, modify, and distribute this
9+
# software is freely granted, provided that this notice
10+
# is preserved.
11+
# ====================================================
12+
#
13+
#
14+
15+
#
16+
# There are two options in making libm at fdlibm compile time:
17+
# _IEEE_LIBM --- IEEE libm; smaller, and somewhat faster
18+
# _MULTI_LIBM --- Support multi-standard at runtime by
19+
# imposing wrapper functions defined in
20+
# fdlibm.h:
21+
# _IEEE_MODE -- IEEE
22+
# _XOPEN_MODE -- X/OPEN
23+
# _POSIX_MODE -- POSIX/ANSI
24+
# _SVID3_MODE -- SVID
25+
#
26+
# Here is how to set up CFLAGS to create the desired libm at
27+
# compile time:
28+
#
29+
# CFLAGS = -D_IEEE_LIBM ... IEEE libm (recommended)
30+
# CFLAGS = -D_SVID3_MODE ... Multi-standard supported
31+
# libm with SVID as the
32+
# default standard
33+
# CFLAGS = -D_XOPEN_MODE ... Multi-standard supported
34+
# libm with XOPEN as the
35+
# default standard
36+
# CFLAGS = -D_POSIX_MODE ... Multi-standard supported
37+
# libm with POSIX as the
38+
# default standard
39+
# CFLAGS = ... Multi-standard supported
40+
# libm with IEEE as the
41+
# default standard
42+
#
43+
# NOTE: if scalb's second arguement is an int, then one must
44+
# define _SCALB_INT in CFLAGS. The default prototype of scalb
45+
# is double scalb(double, double)
46+
#
47+
48+
49+
#
50+
# Default IEEE libm
51+
#
52+
CFLAGS = -D_IEEE_LIBM
53+
54+
CC = cc
55+
56+
INCFILES = fdlibm.h
57+
.INIT: $(INCFILES)
58+
.KEEP_STATE:
59+
src = k_standard.c k_rem_pio2.c \
60+
k_cos.c k_sin.c k_tan.c \
61+
e_acos.c e_acosh.c e_asin.c e_atan2.c \
62+
e_atanh.c e_cosh.c e_exp.c e_fmod.c \
63+
e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \
64+
e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c \
65+
e_log.c e_log10.c e_pow.c e_rem_pio2.c e_remainder.c \
66+
e_scalb.c e_sinh.c e_sqrt.c \
67+
w_acos.c w_acosh.c w_asin.c w_atan2.c \
68+
w_atanh.c w_cosh.c w_exp.c w_fmod.c \
69+
w_gamma.c w_gamma_r.c w_hypot.c w_j0.c \
70+
w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
71+
w_log.c w_log10.c w_pow.c w_remainder.c \
72+
w_scalb.c w_sinh.c w_sqrt.c \
73+
s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c \
74+
s_cos.c s_erf.c s_expm1.c s_fabs.c s_finite.c s_floor.c \
75+
s_frexp.c s_ilogb.c s_isnan.c s_ldexp.c s_lib_version.c \
76+
s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c \
77+
s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c \
78+
s_tan.c s_tanh.c
79+
80+
obj = k_standard.o k_rem_pio2.o \
81+
k_cos.o k_sin.o k_tan.o \
82+
e_acos.o e_acosh.o e_asin.o e_atan2.o \
83+
e_atanh.o e_cosh.o e_exp.o e_fmod.o \
84+
e_gamma.o e_gamma_r.o e_hypot.o e_j0.o \
85+
e_j1.o e_jn.o e_lgamma.o e_lgamma_r.o \
86+
e_log.o e_log10.o e_pow.o e_rem_pio2.o e_remainder.o \
87+
e_scalb.o e_sinh.o e_sqrt.o \
88+
w_acos.o w_acosh.o w_asin.o w_atan2.o \
89+
w_atanh.o w_cosh.o w_exp.o w_fmod.o \
90+
w_gamma.o w_gamma_r.o w_hypot.o w_j0.o \
91+
w_j1.o w_jn.o w_lgamma.o w_lgamma_r.o \
92+
w_log.o w_log10.o w_pow.o w_remainder.o \
93+
w_scalb.o w_sinh.o w_sqrt.o \
94+
s_asinh.o s_atan.o s_cbrt.o s_ceil.o s_copysign.o \
95+
s_cos.o s_erf.o s_expm1.o s_fabs.o s_finite.o s_floor.o \
96+
s_frexp.o s_ilogb.o s_isnan.o s_ldexp.o s_lib_version.o \
97+
s_log1p.o s_logb.o s_matherr.o s_modf.o s_nextafter.o \
98+
s_rint.o s_scalbn.o s_signgam.o s_significand.o s_sin.o \
99+
s_tan.o s_tanh.o
100+
101+
all: libm.a
102+
103+
libm.a : $(obj)
104+
ar cru libm.a $(obj)
105+
ranlib libm.a
106+
107+
source: $(src) README
108+
109+
clean:
110+
/bin/rm -f $(obj) a.out libm.a
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#
2+
# @(#)Makefile 1.4 95/01/18
3+
#
4+
# ====================================================
5+
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6+
#
7+
# Developed at SunSoft, a Sun Microsystems, Inc. business.
8+
# Permission to use, copy, modify, and distribute this
9+
# software is freely granted, provided that this notice
10+
# is preserved.
11+
# ====================================================
12+
#
13+
#
14+
15+
#
16+
# There are two options in making libm at fdlibm compile time:
17+
# _IEEE_LIBM --- IEEE libm; smaller, and somewhat faster
18+
# _MULTI_LIBM --- Support multi-standard at runtime by
19+
# imposing wrapper functions defined in
20+
# fdlibm.h:
21+
# _IEEE_MODE -- IEEE
22+
# _XOPEN_MODE -- X/OPEN
23+
# _POSIX_MODE -- POSIX/ANSI
24+
# _SVID3_MODE -- SVID
25+
#
26+
# Here is how to set up CFLAGS to create the desired libm at
27+
# compile time:
28+
#
29+
# CFLAGS = -D_IEEE_LIBM ... IEEE libm (recommended)
30+
# CFLAGS = -D_SVID3_MODE ... Multi-standard supported
31+
# libm with SVID as the
32+
# default standard
33+
# CFLAGS = -D_XOPEN_MODE ... Multi-standard supported
34+
# libm with XOPEN as the
35+
# default standard
36+
# CFLAGS = -D_POSIX_MODE ... Multi-standard supported
37+
# libm with POSIX as the
38+
# default standard
39+
# CFLAGS = ... Multi-standard supported
40+
# libm with IEEE as the
41+
# default standard
42+
#
43+
# NOTE: if scalb's second arguement is an int, then one must
44+
# define _SCALB_INT in CFLAGS. The default prototype of scalb
45+
# is double scalb(double, double)
46+
#
47+
48+
prefix = @prefix@
49+
50+
AR = @AR@
51+
52+
CC = @CC@
53+
54+
#
55+
# Default IEEE libm
56+
#
57+
CFLAGS = @CFLAGS@ -D_IEEE_LIBM
58+
59+
CHMOD = @CHMOD@
60+
61+
CP = @CP@
62+
63+
INCFILES = fdlibm.h
64+
65+
LDFLAGS = @LDFLAGS@
66+
67+
LIB = libfdm.a
68+
69+
LIBS = @LIBS@
70+
71+
RANLIB = @RANLIB@
72+
73+
RM = @RM@ -f
74+
75+
.INIT: $(INCFILES)
76+
77+
.KEEP_STATE:
78+
79+
src = k_standard.c k_rem_pio2.c \
80+
k_cos.c k_sin.c k_tan.c \
81+
e_acos.c e_acosh.c e_asin.c e_atan2.c \
82+
e_atanh.c e_cosh.c e_exp.c e_fmod.c \
83+
e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \
84+
e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c \
85+
e_log.c e_log10.c e_pow.c e_rem_pio2.c e_remainder.c \
86+
e_scalb.c e_sinh.c e_sqrt.c \
87+
w_acos.c w_acosh.c w_asin.c w_atan2.c \
88+
w_atanh.c w_cosh.c w_exp.c w_fmod.c \
89+
w_gamma.c w_gamma_r.c w_hypot.c w_j0.c \
90+
w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
91+
w_log.c w_log10.c w_pow.c w_remainder.c \
92+
w_scalb.c w_sinh.c w_sqrt.c \
93+
s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c \
94+
s_cos.c s_erf.c s_expm1.c s_fabs.c s_finite.c s_floor.c \
95+
s_frexp.c s_ilogb.c s_isnan.c s_ldexp.c s_lib_version.c \
96+
s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c \
97+
s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c \
98+
s_tan.c s_tanh.c
99+
100+
obj = k_standard.o k_rem_pio2.o \
101+
k_cos.o k_sin.o k_tan.o \
102+
e_acos.o e_acosh.o e_asin.o e_atan2.o \
103+
e_atanh.o e_cosh.o e_exp.o e_fmod.o \
104+
e_gamma.o e_gamma_r.o e_hypot.o e_j0.o \
105+
e_j1.o e_jn.o e_lgamma.o e_lgamma_r.o \
106+
e_log.o e_log10.o e_pow.o e_rem_pio2.o e_remainder.o \
107+
e_scalb.o e_sinh.o e_sqrt.o \
108+
w_acos.o w_acosh.o w_asin.o w_atan2.o \
109+
w_atanh.o w_cosh.o w_exp.o w_fmod.o \
110+
w_gamma.o w_gamma_r.o w_hypot.o w_j0.o \
111+
w_j1.o w_jn.o w_lgamma.o w_lgamma_r.o \
112+
w_log.o w_log10.o w_pow.o w_remainder.o \
113+
w_scalb.o w_sinh.o w_sqrt.o \
114+
s_asinh.o s_atan.o s_cbrt.o s_ceil.o s_copysign.o \
115+
s_cos.o s_erf.o s_expm1.o s_fabs.o s_finite.o s_floor.o \
116+
s_frexp.o s_ilogb.o s_isnan.o s_ldexp.o s_lib_version.o \
117+
s_log1p.o s_logb.o s_matherr.o s_modf.o s_nextafter.o \
118+
s_rint.o s_scalbn.o s_signgam.o s_significand.o s_sin.o \
119+
s_tan.o s_tanh.o
120+
121+
all: $(LIB)
122+
123+
check:
124+
@echo This package does not have a validation suite.
125+
126+
clean:
127+
-$(RM) *~ #* core a.out
128+
129+
distclean: mostlyclean
130+
-$(RM) $(LIB)
131+
-$(RM) -r autom4te.cache/
132+
-$(RM) config.cache config.log config.status Makefile
133+
134+
install: $(LIB) uninstall
135+
$(CP) $(LIB) $(prefix)/lib/$(LIB)
136+
$(CHMOD) 664 $(prefix)/lib/$(LIB)
137+
$(RANLIB) $(prefix)/lib/$(LIB) || true
138+
139+
$(LIB) : $(obj)
140+
$(AR) cru $(LIB) $(obj)
141+
$(RANLIB) $(LIB) || true
142+
143+
maintainer-clean: distclean
144+
@echo "This command is intended for maintainers to use;"
145+
@echo "it deletes files that may require special tools to rebuild."
146+
-$(RM) configure
147+
148+
mostlyclean: clean
149+
-$(RM) $(obj)
150+
151+
source: $(src) README
152+
153+
uninstall:
154+
-$(RM) $(prefix)/lib/$(LIB)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Makefile for building Nicolas Cellier's development of fdlibm in a remote
2+
# directory.
3+
TP:=../../platforms/Cross/third-party
4+
FDLIBM:=fdlibm
5+
VPATH=$(TP)/$(FDLIBM):.
6+
include $(TP)/$(FDLIBM)/Makefile

0 commit comments

Comments
 (0)