Skip to content

Commit 61ded57

Browse files
committed
Use GNU as instead of nasm.
1 parent df910c8 commit 61ded57

File tree

5 files changed

+32
-31
lines changed

5 files changed

+32
-31
lines changed

.github/workflows/all_ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Install system dependencies
19-
run: sudo apt install nasm lld
19+
run: sudo apt install lld
2020
- name: Install D compiler
2121
uses: dlang-community/setup-dlang@v1
2222
with:

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ been tested is to use [Homebrew][40], a package manager for OS X. After
6868
installing it by following instructions from the web page, run the command
6969
`brew install llvm11`, followed by `LLVM_CONFIG=llvm-config-11 make` . If you
7070
are using [MacPorts][41] instead, you can run `sudo port install llvm-11`,
71-
followed by `LLVM_CONFIG=llvm-config-mp-11 make` . You'll also need a recent
72-
version of `nasm`; if `nasm` does not recognise the `macho64` output format, try
73-
upgrading `nasm` to a newer version.
71+
followed by `LLVM_CONFIG=llvm-config-mp-11 make` .
7472

7573
[40]: http://brew.sh/
7674
[41]: http://www.macports.org

makefile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
DMD ?= dmd
2-
NASM ?= nasm
32
RDMD ?= rdmd
3+
AS ?= as
44

5-
ARCHFLAG ?= -m64
6-
DFLAGS = $(ARCHFLAG) -Isrc -w -debug -g
5+
ARCH ?= $(shell uname -m)
76
PLATFORM = $(shell uname -s)
87

8+
ARCHFLAG ?= -m64
9+
DFLAGS = $(ARCHFLAG) -Isrc -w -debug -g
910
# DFLAGS = $(ARCHFLAG) -w -O -release
1011

11-
# dmd.conf doesn't set the proper -L flags.
12-
# Fix it here until dmd installer is updated
13-
ifeq ($(PLATFORM),Darwin)
14-
LD_PATH ?= /Library/D/dmd/lib
15-
endif
12+
ASFLAGS ?=
1613

17-
NASMFLAGS ?=
1814
LDFLAGS ?=
1915
ifdef LD_PATH
2016
override LDFLAGS += $(addprefix -L, $(LD_PATH))
@@ -26,15 +22,12 @@ ifeq ($(PLATFORM),Linux)
2622
override LDFLAGS += -fuse-ld=lld
2723
endif
2824
override LDFLAGS += -lstdc++ -export-dynamic
29-
override NASMFLAGS += -f elf64
3025
endif
3126
ifeq ($(PLATFORM),Darwin)
3227
override LDFLAGS += -lc++ -Wl,-export_dynamic
33-
override NASMFLAGS += -f macho64
3428
endif
3529
ifeq ($(PLATFORM),FreeBSD)
3630
override LDFLAGS += -lc++
37-
override NASMFLAGS += -f elf64
3831
endif
3932

4033
# To make sure make calls all

sdlib/sdrt.mak

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ LIBSDRT_OSX_OBJ = $(LIBSDRT_OSX_OBJ_C) $(LIBSDRT_OSX_OBJ_D)
1818
LIBSDRT_X64_SRC = $(wildcard sdlib/sys/x64/*.asm)
1919
LIBSDRT_X64_OBJ = $(LIBSDRT_X64_SRC:sdlib/sys/x64/%.asm=obj/x64/%.o)
2020

21+
LIBSDRT_ARM64_SRC = $(wildcard sdlib/sys/arm64/*.asm)
22+
LIBSDRT_ARM64_OBJ = $(LIBSDRT_X64_SRC:sdlib/sys/arm64/%.asm=obj/arm64/%.o)
23+
2124
COMMON_LIB_DEPS = obj/object.o obj/sdlib/gc.o obj/sdlib/rt.o obj/sdlib/stdc.o \
22-
obj/sdlib/sync.o $(LIBSDRT_X64_OBJ)
25+
obj/sdlib/sync.o
2326
LIBSDRT_DEPS = $(COMMON_LIB_DEPS) obj/sdlib/d.o obj/sdlib/sdc.o
2427
LIBDMDALLOC_DEPS = $(COMMON_LIB_DEPS) obj/sdlib/dmd.o
2528

29+
ifeq ($(ARCH),x86_64)
30+
COMMON_LIB_DEPS += $(LIBSDRT_X64_OBJ)
31+
else ifeq ($(ARCH),arm64)
32+
COMMON_LIB_DEPS += $(LIBSDRT_ARM64_OBJ)
33+
endif
34+
2635
ifeq ($(PLATFORM),Linux)
2736
LIBSDRT_DEPS += obj/sdlib/linux.o
2837
endif
@@ -83,7 +92,7 @@ obj/osx/%.o: sdlib/sys/osx/%.d $(LIBSDRT_OSX_SRC_D) $(SDLIB_DEPS)
8392

8493
obj/x64/%.o: sdlib/sys/x64/%.asm $(LIBSDRT_X64_SRC)
8594
@mkdir -p obj/x64
86-
$(NASM) -o $@ $< $(NASMFLAGS)
95+
$(AS) -o $@ $< $(ASFLAGS)
8796

8897
$(LIBSDRT): $(LIBSDRT_DEPS)
8998
@mkdir -p lib

sdlib/sys/x64/save_regs.asm

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
global __sd_gc_push_registers
1+
.intel_syntax noprefix
2+
.global __sd_gc_push_registers
23

3-
section .text
4+
.section .text
45
__sd_gc_push_registers:
5-
; For some reason, clang seems to use rbp, but gcc rbx (?) so we will do it
6-
; the clang way and push rbx to the stack as a parameter.
6+
# For some reason, clang seems to use rbp, but gcc rbx (?) so we will do it
7+
# the clang way and push rbx to the stack as a parameter.
78
push rbp
89
mov rbp, rsp
9-
; Not using push to make sure we do not mess up with stack alignement.
10-
; Also sub + mov is usually faster than push (not that it matter much here).
10+
# Not using push to make sure we do not mess up with stack alignement.
11+
# Also sub + mov is usually faster than push (not that it matter much here).
1112
sub rsp, 48
12-
; Register r12 to r15 are callee saved so can have live values.
13-
; Other registers are trash or already saved on the stack.
13+
# Register r12 to r15 are callee saved so can have live values.
14+
# Other registers are trash or already saved on the stack.
1415
mov [rbp - 8], rbx
1516
mov [rbp - 16], r12
1617
mov [rbp - 24], r13
1718
mov [rbp - 32], r14
1819
mov [rbp - 40], r15
19-
; While not strictly necessary, it avoids false pointers and make for easier debug.
20+
# While not strictly necessary, it avoids false pointers and make for easier debug.
2021
mov [rbp - 48], rsp
21-
; This method is passed a delegate. rdi contains the context as a first argument
22-
; and rsi, the second argument is the function pointer. rdi do not need any special
23-
; threatement as it is also the first argument when calling the delegate.
22+
# This method is passed a delegate. rdi contains the context as a first argument
23+
# and rsi, the second argument is the function pointer. rdi do not need any special
24+
# threatement as it is also the first argument when calling the delegate.
2425
call rsi
25-
; rsp and rbp are the only callee saved register we modified, no need to restore others.
26+
# rsp and rbp are the only callee saved register we modified, no need to restore others.
2627
mov rsp, rbp
2728
pop rbp
2829
ret

0 commit comments

Comments
 (0)