Skip to content

Commit 4605ed1

Browse files
committed
Use architecture-specific version of math.h
It looks like math.h is the _only_ file that is architecture specific, and apparently I missed it while adding ARM support.
1 parent 96ffabe commit 4605ed1

File tree

7 files changed

+539
-37
lines changed

7 files changed

+539
-37
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ sysroot-%/usr/include: update.sh src/usr/include
2626

2727
sysroot-macos-x86_64: sysroot-macos-x86_64/usr/include sysroot-macos-x86_64/usr/lib/libSystem.dylib
2828
sysroot-macos-x86_64/usr/lib/libSystem.dylib:
29+
mkdir -p sysroot-macos-x86_64/usr/include
30+
cp -rp src/usr/include/x86_64/* sysroot-macos-x86_64/usr/include
2931
mkdir -p $(dir $@)
3032
$(CLANG) $(DYLDFLAGS) --target=x86_64-apple-macos10.12 -o $(dir $@)/libSystem.B.dylib src/x86_64/libSystem.s
3133
ln -sf libSystem.B.dylib $@
3234

3335
sysroot-macos-arm64: sysroot-macos-arm64/usr/include sysroot-macos-arm64/usr/lib/libSystem.dylib
3436
sysroot-macos-arm64/usr/lib/libSystem.dylib:
37+
mkdir -p sysroot-macos-arm64/usr/include
38+
cp -rp src/usr/include/arm64/* sysroot-macos-arm64/usr/include
3539
mkdir -p $(dir $@)
3640
$(CLANG) $(DYLDFLAGS) --target=arm64-apple-macos11 -o $(dir $@)/libSystem.B.dylib src/x86_64/libSystem.s
3741
ln -sf libSystem.B.dylib $@

generate-stubs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def generateStubs(sysroot, outfile, target):
3636

3737
# Parse the src/libSystem.h file to get a list of functions declared in libSystem.
3838
index = clang.cindex.Index.create()
39-
args = args=['--sysroot='+sysroot, '-Werror', '--target='+target]
39+
arch = target.split('-')[0]
40+
args = args=['--sysroot='+sysroot, '-isystem', sysroot+'/usr/include/'+arch, '-Werror', '--target='+target]
4041
tu = index.parse('src/libSystem.h', args=args)
4142
if len(tu.diagnostics):
4243
print('failed to extract function stubs using %s:' % args)

src/arm64/libSystem.s

+2-35
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,18 @@ ___error:
2828
.global ___fpclassify
2929
___fpclassify:
3030

31-
.global ___fpclassifyd
32-
___fpclassifyd:
33-
3431
.global ___fpclassifyf
3532
___fpclassifyf:
3633

37-
.global ___inf
38-
___inf:
39-
40-
.global ___inff
41-
___inff:
42-
43-
.global ___infl
44-
___infl:
34+
.global ___fpclassifyl
35+
___fpclassifyl:
4536

4637
.global ___math_errhandling
4738
___math_errhandling:
4839

4940
.global ___mb_cur_max
5041
___mb_cur_max:
5142

52-
.global ___nan
53-
___nan:
54-
5543
.global ___opendir2
5644
___opendir2:
5745

@@ -415,9 +403,6 @@ _dprintf:
415403
.global _drand48
416404
_drand48:
417405

418-
.global _drem
419-
_drem:
420-
421406
.global _dup
422407
_dup:
423408

@@ -631,9 +616,6 @@ _filesec_set_property:
631616
.global _filesec_unset_property
632617
_filesec_unset_property:
633618

634-
.global _finite
635-
_finite:
636-
637619
.global _flock
638620
_flock:
639621

@@ -796,9 +778,6 @@ _futimens:
796778
.global _fwrite
797779
_fwrite:
798780

799-
.global _gamma
800-
_gamma:
801-
802781
.global _gcvt
803782
_gcvt:
804783

@@ -1183,9 +1162,6 @@ _madvise:
11831162
.global _malloc
11841163
_malloc:
11851164

1186-
.global _matherr
1187-
_matherr:
1188-
11891165
.global _mblen
11901166
_mblen:
11911167

@@ -1618,9 +1594,6 @@ _rintf:
16181594
.global _rintl
16191595
_rintl:
16201596

1621-
.global _rinttol
1622-
_rinttol:
1623-
16241597
.global _rmdir
16251598
_rmdir:
16261599

@@ -1633,9 +1606,6 @@ _roundf:
16331606
.global _roundl
16341607
_roundl:
16351608

1636-
.global _roundtol
1637-
_roundtol:
1638-
16391609
.global _rpmatch
16401610
_rpmatch:
16411611

@@ -1804,9 +1774,6 @@ _signal:
18041774
.global _signgam
18051775
_signgam:
18061776

1807-
.global _significand
1808-
_significand:
1809-
18101777
.global _sin
18111778
_sin:
18121779

0 commit comments

Comments
 (0)