Skip to content

Commit

Permalink
Fixups for AppleClang toolchain
Browse files Browse the repository at this point in the history
* llvm-ar has no 'D' option
* no support for GAS .type option

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
  • Loading branch information
gmbr3 committed Jun 7, 2024
1 parent 214af5f commit 788e724
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
15 changes: 12 additions & 3 deletions Make.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
&& [ $(GCCMINOR) -ge "7" ] ) ) \
&& echo 1)

AR_IS_LLVM := $(shell $(AR) --version 2>&1 | grep -q 'LLVM' && echo 1)
IS_APPLE := $(shell $(CC) -dumpmachine 2>&1 | grep -q 'darwin' && echo 1)
ifeq ($(IS_APPLE),1)
AR_IS_LLVM = 1
endif

#
# Where to build the package
#
Expand Down Expand Up @@ -220,10 +226,13 @@ ifneq ($(IS_MINGW32),)
CFLAGS += -Wno-error=maybe-uninitialized -Wno-maybe-uninitialized
endif

ifeq ($(V),1)
ARFLAGS := rDv
ifeq ($(AR_IS_LLVM),1)
ARFLAGS = -r
else
ARFLAGS := rD
ARFLAGS = -rD
endif
ifeq ($(V),1)
ARFLAGS += v
endif
ASFLAGS += $(ARCH3264)
LDFLAGS += -nostdlib
Expand Down
6 changes: 4 additions & 2 deletions gnuefi/crt0-efi-aarch64.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
.text
.align 12

.globl _start
.type _start,%function
.globl _start
#ifndef __APPLE__
.type _start,%function
#endif
_start:
stp x29, x30, [sp, #-32]!
mov x29, sp
Expand Down
6 changes: 4 additions & 2 deletions gnuefi/crt0-efi-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
.text
.align 4

.globl _start
.type _start,%function
.globl _start
#ifndef __APPLE__
.type _start,%function
#endif
_start:
subq $8, %rsp
pushq %rcx
Expand Down
12 changes: 8 additions & 4 deletions lib/aarch64/setjmp.S
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ BASIS,
#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]

.globl setjmp
.type setjmp, @function
.globl setjmp
#ifndef __APPLE__
.type setjmp, @function
#endif
setjmp:
mov x16, sp
GPR_LAYOUT
Expand All @@ -48,8 +50,10 @@ setjmp:
#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]

.globl longjmp
.type longjmp, @function
.globl longjmp
#ifndef __APPLE__
.type longjmp, @function
#endif
longjmp:
GPR_LAYOUT
FPR_LAYOUT
Expand Down
4 changes: 4 additions & 0 deletions lib/x86_64/setjmp.S
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.text
.globl setjmp
#ifndef __APPLE__
#ifndef __MINGW32__
.type setjmp, @function
#else
.def setjmp; .scl 2; .type 32; .endef
#endif
#endif
setjmp:
pop %rsi
movq %rbx,0x00(%rdi)
Expand All @@ -20,11 +22,13 @@ setjmp:
ret

.globl longjmp
#ifndef __APPLE__
#ifndef __MINGW32__
.type longjmp, @function
#else
.def longjmp; .scl 2; .type 32; .endef
#endif
#endif
longjmp:
movl %esi, %eax
movq 0x00(%rdi), %rbx
Expand Down

0 comments on commit 788e724

Please sign in to comment.