Skip to content

Commit 4b7918f

Browse files
committed
Remove OpenLibm and leverage native Julia implementations
Link to the system libm
1 parent 210c5b5 commit 4b7918f

File tree

14 files changed

+15
-140
lines changed

14 files changed

+15
-140
lines changed

Make.inc

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ USE_SYSTEM_LLVM:=0
4545
USE_SYSTEM_LIBUNWIND:=0
4646
DISABLE_LIBUNWIND:=0
4747
USE_SYSTEM_PCRE:=0
48-
USE_SYSTEM_LIBM:=0
49-
USE_SYSTEM_OPENLIBM:=0
50-
UNTRUSTED_SYSTEM_LIBM:=0
5148
USE_SYSTEM_DSFMT:=0
5249
USE_SYSTEM_LIBBLASTRAMPOLINE:=0
5350
USE_SYSTEM_BLAS:=0
@@ -1145,14 +1142,6 @@ LIBLAPACKNAME := liblapack
11451142
endif
11461143
endif
11471144

1148-
ifeq ($(USE_SYSTEM_LIBM), 1)
1149-
LIBM := -lm
1150-
LIBMNAME := libm
1151-
else
1152-
LIBM := -lopenlibm
1153-
LIBMNAME := libopenlibm
1154-
endif
1155-
11561145
ifeq ($(USE_SYSTEM_LIBUV), 1)
11571146
LIBUV := $(LOCALBASE)/lib/libuv-julia.a
11581147
LIBUV_INC := $(LOCALBASE)/include
@@ -1236,7 +1225,7 @@ CSL_NEXT_GLIBCXX_VERSION=GLIBCXX_3\.4\.31|GLIBCXX_3\.5\.|GLIBCXX_4\.
12361225
# Note: we explicitly _do not_ define `CSL` here, since it requires some more
12371226
# advanced techniques to decide whether it should be installed from a BB source
12381227
# or not. See `deps/csl.mk` for more detail.
1239-
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP LLD LIBTRACYCLIENT
1228+
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE GMP MBEDTLS LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP LLD LIBTRACYCLIENT
12401229
define SET_BB_DEFAULT
12411230
# First, check to see if BB is disabled on a global setting
12421231
ifeq ($$(USE_BINARYBUILDER),0)
@@ -1366,7 +1355,6 @@ ifeq ($(ARCH),i686)
13661355
JLDFLAGS += -Wl,--large-address-aware
13671356
endif
13681357
JCPPFLAGS += -D_WIN32_WINNT=0x0502
1369-
UNTRUSTED_SYSTEM_LIBM := 1
13701358
# Use hard links for files on windows, rather than soft links
13711359
# https://stackoverflow.com/questions/3648819/how-to-make-a-symbolic-link-with-cygwin-in-windows-7
13721360
# Usage: $(WIN_MAKE_HARD_LINK) <source> <target>
@@ -1441,12 +1429,6 @@ USE_BINARYBUILDER_OPENBLAS := 0
14411429
USE_BINARYBUILDER_LIBSUITESPARSE := 0
14421430
endif
14431431

1444-
ifeq ($(USE_SYSTEM_LIBM),1)
1445-
# If we're using system libm, disable BB OpenLibm
1446-
USE_BINARYBUILDER_OPENLIBM := 0
1447-
endif
1448-
1449-
14501432
# Note: we're passing *FLAGS here computed based on your system compiler to
14511433
# clang. If that causes you problems, you might want to build and/or run
14521434
# specific clang-sa-* files with clang explicitly selected:
@@ -1602,20 +1584,13 @@ endif
16021584
LIBSTDCXX_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBSTDCXX_NAME))
16031585
endif
16041586

1605-
1606-
# USE_SYSTEM_LIBM and USE_SYSTEM_OPENLIBM causes it to get symlinked into build_private_shlibdir
1607-
ifeq ($(USE_SYSTEM_LIBM),1)
1608-
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1609-
else ifeq ($(USE_SYSTEM_OPENLIBM),1)
1610-
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1611-
else
1612-
LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1613-
endif
1614-
LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1587+
# Symlink system libm
1588+
LIBMNAME := libm
1589+
#LIBM_BUILD_DEPLIB := $(call dep_lib_path,$(build_libdir),$(build_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
1590+
#LIBM_INSTALL_DEPLIB := $(call dep_lib_path,$(libdir),$(private_shlibdir)/$(LIBMNAME).$(SHLIB_EXT))
16151591

16161592
# We list:
16171593
# * libgcc_s, because FreeBSD needs to load ours, not the system one.
1618-
# * libopenlibm, because Windows has an untrustworthy libm, and we want to use ours more than theirs
16191594
# * libstdc++, because while performing `libstdc++` probing we need to
16201595
# know the path to the bundled `libstdc++` library.
16211596
# * libjulia-internal, which must always come second-to-last.
@@ -1637,30 +1612,26 @@ endef
16371612

16381613
LOADER_BUILD_DEP_LIBS = $(call build_deplibs, \
16391614
$(LIBGCC_BUILD_DEPLIB) \
1640-
$(LIBM_BUILD_DEPLIB) \
16411615
@$(LIBSTDCXX_BUILD_DEPLIB) \
16421616
@$(LIBJULIAINTERNAL_BUILD_DEPLIB) \
16431617
@$(LIBJULIACODEGEN_BUILD_DEPLIB) \
16441618
)
16451619

16461620
LOADER_DEBUG_BUILD_DEP_LIBS = $(call build_deplibs, \
16471621
$(LIBGCC_BUILD_DEPLIB) \
1648-
$(LIBM_BUILD_DEPLIB) \
16491622
@$(LIBSTDCXX_BUILD_DEPLIB) \
16501623
@$(LIBJULIAINTERNAL_DEBUG_BUILD_DEPLIB) \
16511624
@$(LIBJULIACODEGEN_DEBUG_BUILD_DEPLIB) \
16521625
)
16531626

16541627
LOADER_INSTALL_DEP_LIBS = $(call build_deplibs, \
16551628
$(LIBGCC_INSTALL_DEPLIB) \
1656-
$(LIBM_INSTALL_DEPLIB) \
16571629
@$(LIBSTDCXX_INSTALL_DEPLIB) \
16581630
@$(LIBJULIAINTERNAL_INSTALL_DEPLIB) \
16591631
@$(LIBJULIACODEGEN_INSTALL_DEPLIB) \
16601632
)
16611633
LOADER_DEBUG_INSTALL_DEP_LIBS = $(call build_deplibs, \
16621634
$(LIBGCC_INSTALL_DEPLIB) \
1663-
$(LIBM_INSTALL_DEPLIB) \
16641635
@$(LIBSTDCXX_INSTALL_DEPLIB) \
16651636
@$(LIBJULIAINTERNAL_DEBUG_INSTALL_DEPLIB) \
16661637
@$(LIBJULIACODEGEN_DEBUG_INSTALL_DEPLIB) \

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM $(LLVM_SHARED_LIB_NAME)
226226
endif
227227
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind
228228

229-
ifeq ($(USE_SYSTEM_LIBM),0)
230-
JL_PRIVATE_LIBS-$(USE_SYSTEM_OPENLIBM) += libopenlibm
231-
endif
232-
233229
JL_PRIVATE_LIBS-$(USE_SYSTEM_BLAS) += $(LIBBLASNAME)
234230
ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
235231
JL_PRIVATE_LIBS-$(USE_SYSTEM_LAPACK) += $(LIBLAPACKNAME)
@@ -291,13 +287,13 @@ endif
291287

292288
# We have a single exception; we want 7z.dll to live in private_libexecdir, not bindir, so that 7z.exe can find it.
293289
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(private_libexecdir)/
294-
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
295290
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
296291
# The rest are compiler dependencies, as an example memcpy is exported by msvcrt
297292
# These are files from mingw32 and required for creating shared libraries like our caches.
298293
-$(INSTALL_M) $(build_libdir)/libgcc_s.a $(DESTDIR)$(libdir)/
299294
-$(INSTALL_M) $(build_libdir)/libgcc.a $(DESTDIR)$(libdir)/
300295
-$(INSTALL_M) $(build_libdir)/libmsvcrt.a $(DESTDIR)$(libdir)/
296+
301297
else
302298

303299
# Copy over .dSYM directories directly for Darwin

base/Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ ifeq ($(XC_HOST),)
4848
else
4949
@echo "const MACHINE = \"$(XC_HOST)\"" >> $@
5050
endif
51-
@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
5251
ifeq ($(USE_BLAS64), 1)
5352
@echo "const USE_BLAS64 = true" >> $@
5453
else
@@ -218,13 +217,7 @@ $(build_bindir)/lld$(EXE):
218217
ln -svf "$(LLD_PATH)" "$@"
219218

220219
# the following excludes: libuv.a, libutf8proc.a
221-
222-
ifneq ($(USE_SYSTEM_LIBM),0)
223-
$(eval $(call symlink_system_library,LIBM,$(LIBMNAME)))
224-
else ifneq ($(USE_SYSTEM_OPENLIBM),0)
225-
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
226-
endif
227-
220+
#$(eval $(call symlink_system_library,LIBM,$(LIBMNAME)))
228221
# On macOS, libgcc_s has soversion 1.1 always on aarch64 and only for GCC 12+
229222
# (-> libgfortran 5) on x86_64
230223
ifeq ($(OS),Darwin)

base/fastmath.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ sub_fast(x::T, y::T) where {T<:FloatTypes} = sub_float_fast(x, y)
165165
mul_fast(x::T, y::T) where {T<:FloatTypes} = mul_float_fast(x, y)
166166
div_fast(x::T, y::T) where {T<:FloatTypes} = div_float_fast(x, y)
167167

168+
168169
add_fast(x::T, y::T, zs::T...) where {T<:FloatTypes} =
169170
add_fast(add_fast(x, y), zs...)
170171
mul_fast(x::T, y::T, zs::T...) where {T<:FloatTypes} =

base/linking.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function link_image_cmd(path, out)
155155
SHLIBDIR = "-L$(shlibdir())"
156156
LIBS = is_debug() ? ("-ljulia-debug", "-ljulia-internal-debug") : ("-ljulia", "-ljulia-internal")
157157
@static if Sys.iswindows()
158-
LIBS = (LIBS..., "-lopenlibm", "-lssp", "-lgcc_s", "-lgcc", "-lmsvcrt")
158+
LIBS = (LIBS..., "-lssp", "-lgcc_s", "-lgcc", "-lucrt")
159159
end
160160

161161
V = VERBOSE[] ? "--verbose" : ""

base/math.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,6 @@ log(b::Number, x::Number) = log(promote(b,x)...)
396396

397397
# type specific math functions
398398

399-
const libm = Base.libm_name
400-
401399
# functions with no domain error
402400
"""
403401
sinh(x)
@@ -1164,7 +1162,6 @@ function rem(x::T, p::T, ::RoundingMode{:Nearest}) where T<:IEEEFloat
11641162
return flipsign(x, oldx)
11651163
end
11661164

1167-
11681165
"""
11691166
modf(x)
11701167

contrib/julia-config.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function ldlibs(doframework)
7171
(Sys.isapple() ? string() : "-Wl,-rpath,$(shell_escape(private_libDir())) ") *
7272
"-l$libname"
7373
else
74-
return "-l$libname -lopenlibm"
74+
return "-l$libname -lm"
7575
end
7676
end
7777

contrib/refresh_checksums.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CLANG_TRIPLETS=$(filter %-darwin %-freebsd,$(TRIPLETS))
2424
NON_CLANG_TRIPLETS=$(filter-out %-darwin %-freebsd,$(TRIPLETS))
2525

2626
# These are the projects currently using BinaryBuilder; both GCC-expanded and non-GCC-expanded:
27-
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib libsuitesparse openlibm blastrampoline libtracyclient
27+
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib libsuitesparse blastrampoline libtracyclient
2828
BB_GCC_EXPANDED_PROJECTS=openblas csl
2929
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools lld
3030
# These are non-BB source-only deps

deps/Makefile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ BUILDDIR := $(BUILDDIR)$(MAYBE_HOST)
2323
# if you are adding a new target, it can help to copy an similar, existing target
2424
#
2525
# autoconf configure-driven scripts: pcre unwind gmp mpfr patchelf libuv curl
26-
# custom Makefile rules: openlibm dsfmt libsuitesparse lapack blastrampoline openblas utf8proc objconv libwhich
26+
# custom Makefile rules: dsfmt libsuitesparse lapack blastrampoline openblas utf8proc objconv libwhich
2727
# CMake libs: llvm llvmunwind libgit2 libssh2 mbedtls libtracyclient
2828
#
29-
# downloadable via git: llvm-svn, libuv, libopenlibm, utf8proc, libgit2, libssh2, libtracyclient
29+
# downloadable via git: llvm-svn, libuv, utf8proc, libgit2, libssh2, libtracyclient
3030
#
3131
# to debug 'define' rules, replace eval at the usage site with info or error
3232

@@ -82,12 +82,6 @@ PATCHELF_BIN := $(CUSTOM_LD_LIBRARY_PATH) $(PATCHELF)
8282

8383
## USE_SYSTEM_LIBS options
8484

85-
ifeq ($(USE_SYSTEM_OPENLIBM), 0)
86-
ifeq ($(USE_SYSTEM_LIBM), 0)
87-
DEP_LIBS += openlibm
88-
endif
89-
endif
90-
9185
ifeq ($(USE_SYSTEM_DSFMT), 0)
9286
DEP_LIBS += dsfmt
9387
endif
@@ -190,7 +184,7 @@ DEP_LIBS_STAGED := $(DEP_LIBS)
190184

191185
# list all targets
192186
DEP_LIBS_STAGED_ALL := llvm llvm-tools clang llvmunwind unwind libuv pcre \
193-
openlibm dsfmt blastrampoline openblas lapack gmp mpfr patchelf utf8proc \
187+
dsfmt blastrampoline openblas lapack gmp mpfr patchelf utf8proc \
194188
objconv mbedtls libssh2 nghttp2 curl libgit2 libwhich zlib p7zip csl \
195189
sanitizers libsuitesparse lld libtracyclient ittapi JuliaSyntax
196190
DEP_LIBS_ALL := $(DEP_LIBS_STAGED_ALL)
@@ -232,7 +226,6 @@ include $(SRCDIR)/ittapi.mk
232226
include $(SRCDIR)/llvm.mk
233227
include $(SRCDIR)/libuv.mk
234228
include $(SRCDIR)/pcre.mk
235-
include $(SRCDIR)/openlibm.mk
236229
include $(SRCDIR)/dsfmt.mk
237230
include $(SRCDIR)/objconv.mk
238231
include $(SRCDIR)/blastrampoline.mk

deps/checksums/openlibm

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)