diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff96cf8..0c2166d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,14 @@ jobs: - name: Install Python dependencies run: python -m pip install -e .[dev] - - name: Build ops obj files and runner - run: bash src/copapy/obj/nativecompile.sh + - name: Build ops obj files + run: | + bash src/copapy/obj/nativecompile.sh + + - name: Compile coparun + run: | + mkdir -p bin + gcc -O3 -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror -g src/coparun/runmem.c src/coparun/coparun.c src/coparun/mem_man.c -o bin/coparun #- name: Lint code with flake8 # run: flake8 @@ -82,7 +88,7 @@ jobs: with: vs-version: 'latest' - - name: Compile + - name: Compile coparun shell: cmd run: | mkdir bin diff --git a/notes/crash_windows.md b/notes/crash_windows.md index d9c7240..df094ba 100644 --- a/notes/crash_windows.md +++ b/notes/crash_windows.md @@ -10,7 +10,7 @@ optimization (/O2). For MSVC without optimization and gcc with -O3 there is no i The callee code is composed of stencils build with gcc-12 -O3: -``` bash +``` 1000: f3 0f 1e fa endbr64 1004: 48 83 ec 08 sub $0x8,%rsp 1008: 31 ff xor %edi,%edi @@ -35,7 +35,7 @@ The callee code is composed of stencils build with gcc-12 -O3: ## Caller -The caller (src/copapy/runmem.c): +The caller (src/copapy/runmem.c) calls the callee (here named "entr_point") like so: ``` c case RUN_PROG: @@ -51,7 +51,7 @@ case RUN_PROG: Compiled with MSVC and optimization (crash): -``` bash +``` 00000001400078CA: 8B 1E mov ebx,dword ptr [rsi] 00000001400078CC: 48 8D 0D AD 30 08 lea rcx,[??_C@_0BM@DFBMBFEB@RUN_PROG?5rel_entr_point?$DN?$CFi?6@] 00 @@ -75,7 +75,7 @@ Compiled with MSVC and optimization (crash): Compiled with MSVC and no optimization (no crash): -``` bash +``` 0000000140007978: 48 8B 44 24 70 mov rax,qword ptr [rsp+70h] 000000014000797D: 8B 00 mov eax,dword ptr [rax] 000000014000797F: 89 44 24 4C mov dword ptr [rsp+4Ch],eax diff --git a/src/copapy/generate_stencils.py b/src/copapy/generate_stencils.py index d7cf2e8..ce45862 100644 --- a/src/copapy/generate_stencils.py +++ b/src/copapy/generate_stencils.py @@ -7,7 +7,7 @@ op_signs = {'add': '+', 'sub': '-', 'mul': '*', 'div': '/', def get_function_start() -> str: return """ - int function_start(){ + __attribute__((ms_abi)) int function_start(){ result_int(0); // dummy call instruction before marker gets striped asm volatile (".long 0xE2401F0F"); return 1; @@ -17,7 +17,7 @@ def get_function_start() -> str: def get_function_end() -> str: return """ - int function_end(){ + __attribute__((ms_abi)) int function_end(){ result_int(0); asm volatile (".long 0xE1401F0F"); return 1;