feat(asm&CI): Add support for macho-formats to header.inc and run tests also on MacOS.

Mac was giving errors about position dependent code, so had to add linker flag -Wl,-no_pie to ld & cgo.
This commit is contained in:
Veikko Sariola 2020-11-16 23:59:13 +02:00
parent bca34febcb
commit 335d2af05b
4 changed files with 51 additions and 37 deletions

View File

@ -22,18 +22,26 @@ jobs:
cmakeflags: -GNinja cmakeflags: -GNinja
maker: ninja maker: ninja
gotests: yes gotests: yes
cgo_ldflags:
- os: windows-latest - os: windows-latest
cmakeflags: -GNinja cmakeflags: -GNinja
maker: ninja maker: ninja
asmnasm: C:\Users\runneradmin\nasm\nasm asmnasm: C:\Users\runneradmin\nasm\nasm
gotests: yes gotests: yes
cgo_ldflags:
- os: macos-latest
cmakeflags: -GNinja
maker: ninja
asmnasm: /Users/runner/nasm/nasm
gotests: yes
cgo_ldflags: -Wl,-no_pie # ld on mac is complaining about position dependent code
# TODO: win32 builds didn't quite work out, complains gcc broken # TODO: win32 builds didn't quite work out, complains gcc broken
steps: steps:
- uses: lukka/get-cmake@v3.18.3 - uses: lukka/get-cmake@v3.18.3
- uses: actions/setup-go@v2 - uses: actions/setup-go@v2
if: ${{ matrix.config.gotests == 'yes' }} if: ${{ matrix.config.gotests == 'yes' }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ilammy/setup-nasm@v1.1.0 - uses: ilammy/setup-nasm@v1.2.0
- name: Run ctest - name: Run ctest
env: env:
ASM_NASM: ${{ matrix.config.asmnasm }} ASM_NASM: ${{ matrix.config.asmnasm }}
@ -45,6 +53,8 @@ jobs:
ctest --output-on-failure ctest --output-on-failure
- name: Run go test - name: Run go test
if: ${{ matrix.config.gotests == 'yes' }} if: ${{ matrix.config.gotests == 'yes' }}
env:
CGO_LDFLAGS: ${{ matrix.config.cgo_ldflags }}
run: | run: |
cd go4k cd go4k
go test . ./bridge go test . ./bridge

View File

@ -24,6 +24,10 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest) include(CTest)
endif() endif()
IF(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie")
endif()
enable_language(ASM_NASM) enable_language(ASM_NASM)
# The normal NASM compile object does not include <DEFINES> # The normal NASM compile object does not include <DEFINES>

View File

@ -2,7 +2,7 @@
![Tests](https://github.com/vsariola/sointu/workflows/Tests/badge.svg) ![Tests](https://github.com/vsariola/sointu/workflows/Tests/badge.svg)
A cross-platform modular software synthesizer for small intros, forked from A cross-platform modular software synthesizer for small intros, forked from
[4klang](https://github.com/hzdgopher/4klang). [4klang](https://github.com/hzdgopher/4klang). Supports win32/win64/linux/mac.
Summary Summary
------- -------
@ -21,8 +21,10 @@ Building
Requires [CMake](https://cmake.org), [nasm](https://www.nasm.us/) or Requires [CMake](https://cmake.org), [nasm](https://www.nasm.us/) or
[yasm](https://yasm.tortall.net), and your favorite c-compiler & build tool. [yasm](https://yasm.tortall.net), and your favorite c-compiler & build tool.
Results have been obtained using Visual Studio 2019, gcc&make on linux, and Results have been obtained using Visual Studio 2019, gcc&make on linux,
MinGW&mingw32-make. MinGW&mingw32-make, and ninja&AppleClang.
Additionally, building the tracker requires [go](https://golang.org/).
### Example: building and running CTests using MinGW32 ### Example: building and running CTests using MinGW32
@ -136,11 +138,9 @@ New features since fork
and right channels. See [this example](tests/test_oscillat_unison.asm). and right channels. See [this example](tests/test_oscillat_unison.asm).
- **Supports 32 and 64 bit builds**. The 64-bit version is done with minimal - **Supports 32 and 64 bit builds**. The 64-bit version is done with minimal
changes to get it work, mainly for the future prospect of running the MIDI changes to get it work, mainly for the future prospect of running the MIDI
instrument in 64-bit mode. All the tests are passing so it seems to work. instrument in 64-bit mode. All tests are passing so it seems to work.
- **Supports both Windows and Linux**. Currently, all the tests are compiling - **Supports Windows, Linux and MacOS**. On all three 64-bit platforms,
on Windows and Linux, both 32-bit and 64-bit, and the tests are passing on all tests are passing. Additionally, all tests are passing on windows 32.
64-bit Linux, tested on WSL. 32-bit executables don't run on WSL, so those
remain to be tested.
- **Compiling as a library**. The API is very rudimentary, a single function - **Compiling as a library**. The API is very rudimentary, a single function
render, and between calls, the user is responsible for manipulating render, and between calls, the user is responsible for manipulating
the synth state in a similar way as the actual player does (e.g. triggering/ the synth state in a similar way as the actual player does (e.g. triggering/
@ -151,9 +151,6 @@ New features since fork
Future goals Future goals
------------ ------------
- **Support for mac**. This should be rather easy, as all the macros are
designed for cross-platform support, but as I don't have a mac, I cannot
test this.
- **Find a more general solution for skipping opcodes / early outs**. It's - **Find a more general solution for skipping opcodes / early outs**. It's
probably a new opcode "skip" that skips from the opcode to the next out in probably a new opcode "skip" that skips from the opcode to the next out in
case the signal entering skip and the signal leaving out are both close to case the signal entering skip and the signal leaving out are both close to

View File

@ -10,46 +10,40 @@
%endmacro %endmacro
%ifidn __OUTPUT_FORMAT__,win32 %ifidn __OUTPUT_FORMAT__,win32
; on win32, function f with n parameters is mangled as "_f@n" %define WINDOWS
%define MANGLE_FUNC(f,n) _ %+ f %+ @ %+ n
%define WIN_OR_MAC
%assign BITS 32 %assign BITS 32
; On windows and mac, data label d is mangled as "_d" %define MANGLE_FUNC(f,n) _ %+ f %+ @ %+ n
%define MANGLE_DATA(d) _ %+ d %define MANGLE_DATA(d) _ %+ d
%endif %endif
%ifidn __OUTPUT_FORMAT__,win64 %ifidn __OUTPUT_FORMAT__,win64
; on win32, function f with n parameters is mangled as "_f@n" %define WINDOWS
%define MANGLE_FUNC(f,n) f
%define WIN_OR_MAC
%assign BITS 64 %assign BITS 64
; On windows and mac, data label d is mangled as "_d" %define MANGLE_FUNC(f,n) f
%define MANGLE_DATA(d) d %define MANGLE_DATA(d) d
%endif %endif
%ifidn __OUTPUT_FORMAT__,macho32
%define MACOS
%assign BITS 32
%endif
%ifidn __OUTPUT_FORMAT__,macho64
%define MACOS
%assign BITS 64
%endif
%ifidn __OUTPUT_FORMAT__,elf %ifidn __OUTPUT_FORMAT__,elf
; on linux, function f with n parameters is mangled as "f" %define LINUX
%define MANGLE_FUNC(f,n) f
; On linux, data label d is mangled as "d"
%define MANGLE_DATA(d) d
%assign BITS 32 %assign BITS 32
%endif %endif
%ifidn __OUTPUT_FORMAT__,elf64 %ifidn __OUTPUT_FORMAT__,elf64
%define MANGLE_FUNC(f,n) f %define LINUX
%define MANGLE_DATA(d) d
%assign BITS 64 %assign BITS 64
%endif %endif
%ifidn __OUTPUT_FORMAT__,macho32 %ifdef WINDOWS
; on mac, function f with x parameters is mangled as "_f"
%define MANGLE_FUNC(f,n) _f
%define WIN_OR_MAC
; On windows and mac, data label d is mangled as "_d"
%define MANGLE_DATA(d) _ %+ d
%endif
%ifdef WIN_OR_MAC
; Windows has crinkler so one may put everything in custom sections to aid crinkler. ; Windows has crinkler so one may put everything in custom sections to aid crinkler.
; Maybe mac users need it too ; Maybe mac users need it too
%ifndef DISABLE_SECTIONS %ifndef DISABLE_SECTIONS
@ -61,8 +55,17 @@
%define SECT_DATA(n) section .data align=1 %define SECT_DATA(n) section .data align=1
%define SECT_TEXT(n) section .code align=1 %define SECT_TEXT(n) section .code align=1
%endif %endif
%else %elifdef MACOS
; Linux %define MANGLE_FUNC(f,n) _ %+ f
%define MANGLE_DATA(d) _ %+ d
; macho does not seem to support named sections, so DISABLE_SECTIONS
; is "always on" / ignored
%define SECT_BSS(n) section .bss align=1
%define SECT_DATA(n) section .data align=1
%define SECT_TEXT(n) section .text align=1
%else ; Linux, or hopefully something similar
%define MANGLE_FUNC(f,n) f
%define MANGLE_DATA(d) d
%ifndef DISABLE_SECTIONS %ifndef DISABLE_SECTIONS
%define SECT_BSS(n) section .bss. %+ n nobits alloc noexec write align=1 %define SECT_BSS(n) section .bss. %+ n nobits alloc noexec write align=1
%define SECT_DATA(n) section .data. %+ n progbits alloc noexec write align=1 %define SECT_DATA(n) section .data. %+ n progbits alloc noexec write align=1