Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use architecture-specific version of math.h #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: install Clang
# Note: picking LLVM 15 because that's the one currently included in
# macos-latest. This probably needs an update in the future.
run: brew install llvm@15
- name: Run tests
run: make test CLANG=$(brew --prefix llvm)/bin/clang
run: make test CLANG=$(brew --prefix llvm@15)/bin/clang
Test-Windows:
runs-on: windows-latest
steps:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include versions.inc

SYSROOTS = sysroot-macos-x86_64 sysroot-macos-arm64

CLANG ?= clang-13
CLANG ?= clang

DYLDFLAGS = \
-dynamiclib \
Expand All @@ -26,12 +26,16 @@ sysroot-%/usr/include: update.sh src/usr/include

sysroot-macos-x86_64: sysroot-macos-x86_64/usr/include sysroot-macos-x86_64/usr/lib/libSystem.dylib
sysroot-macos-x86_64/usr/lib/libSystem.dylib:
mkdir -p sysroot-macos-x86_64/usr/include
cp -rp src/usr/include/x86_64/* sysroot-macos-x86_64/usr/include
mkdir -p $(dir $@)
$(CLANG) $(DYLDFLAGS) --target=x86_64-apple-macos10.12 -o $(dir $@)/libSystem.B.dylib src/x86_64/libSystem.s
ln -sf libSystem.B.dylib $@

sysroot-macos-arm64: sysroot-macos-arm64/usr/include sysroot-macos-arm64/usr/lib/libSystem.dylib
sysroot-macos-arm64/usr/lib/libSystem.dylib:
mkdir -p sysroot-macos-arm64/usr/include
cp -rp src/usr/include/arm64/* sysroot-macos-arm64/usr/include
mkdir -p $(dir $@)
$(CLANG) $(DYLDFLAGS) --target=arm64-apple-macos11 -o $(dir $@)/libSystem.B.dylib src/x86_64/libSystem.s
ln -sf libSystem.B.dylib $@
Expand Down
3 changes: 2 additions & 1 deletion generate-stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def generateStubs(sysroot, outfile, target):

# Parse the src/libSystem.h file to get a list of functions declared in libSystem.
index = clang.cindex.Index.create()
args = args=['--sysroot='+sysroot, '-Werror', '--target='+target]
arch = target.split('-')[0]
args = args=['--sysroot='+sysroot, '-isystem', sysroot+'/usr/include/'+arch, '-Werror', '--target='+target]
tu = index.parse('src/libSystem.h', args=args)
if len(tu.diagnostics):
print('failed to extract function stubs using %s:' % args)
Expand Down
37 changes: 2 additions & 35 deletions src/arm64/libSystem.s
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,18 @@ ___error:
.global ___fpclassify
___fpclassify:

.global ___fpclassifyd
___fpclassifyd:

.global ___fpclassifyf
___fpclassifyf:

.global ___inf
___inf:

.global ___inff
___inff:

.global ___infl
___infl:
.global ___fpclassifyl
___fpclassifyl:

.global ___math_errhandling
___math_errhandling:

.global ___mb_cur_max
___mb_cur_max:

.global ___nan
___nan:

.global ___opendir2
___opendir2:

Expand Down Expand Up @@ -415,9 +403,6 @@ _dprintf:
.global _drand48
_drand48:

.global _drem
_drem:

.global _dup
_dup:

Expand Down Expand Up @@ -631,9 +616,6 @@ _filesec_set_property:
.global _filesec_unset_property
_filesec_unset_property:

.global _finite
_finite:

.global _flock
_flock:

Expand Down Expand Up @@ -796,9 +778,6 @@ _futimens:
.global _fwrite
_fwrite:

.global _gamma
_gamma:

.global _gcvt
_gcvt:

Expand Down Expand Up @@ -1183,9 +1162,6 @@ _madvise:
.global _malloc
_malloc:

.global _matherr
_matherr:

.global _mblen
_mblen:

Expand Down Expand Up @@ -1618,9 +1594,6 @@ _rintf:
.global _rintl
_rintl:

.global _rinttol
_rinttol:

.global _rmdir
_rmdir:

Expand All @@ -1633,9 +1606,6 @@ _roundf:
.global _roundl
_roundl:

.global _roundtol
_roundtol:

.global _rpmatch
_rpmatch:

Expand Down Expand Up @@ -1804,9 +1774,6 @@ _signal:
.global _signgam
_signgam:

.global _significand
_significand:

.global _sin
_sin:

Expand Down
Loading
Loading