Skip to content

Commit

Permalink
Use architecture-specific version of math.h
Browse files Browse the repository at this point in the history
It looks like math.h is the _only_ file that is architecture specific,
and apparently I missed it while adding ARM support.
  • Loading branch information
aykevl committed Mar 3, 2024
1 parent 96ffabe commit 4605ed1
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 37 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4605ed1

Please sign in to comment.