From 842e053cbda9e87382ea9d00714af24e257da99b Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 8 Apr 2026 16:24:39 -0400 Subject: [PATCH 1/2] Tweaks to printing; ignore section tests. + Use double quotes on label names to fix #40. + Provide a private parameter to control the os type when printing. + Ignore section tests until #43 is resolved. --- a86/info.rkt | 3 ++- a86/printer.rkt | 33 ++++++++++++++------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/a86/info.rkt b/a86/info.rkt index 0f55389..22c01dc 100644 --- a/a86/info.rkt +++ b/a86/info.rkt @@ -4,5 +4,6 @@ (define deps (list "base" "rackunit" "redex-lib" "redex-gui-lib")) (define scribblings '(("scribblings/a86.scrbl"))) (define test-omit-paths '("scribblings/" - "test/expressions.rkt")) + "test/expressions.rkt" + "test/sections.rkt")) (define pre-install-collection "check-x86.rkt") diff --git a/a86/printer.rkt b/a86/printer.rkt index 5dbb632..fe28851 100644 --- a/a86/printer.rkt +++ b/a86/printer.rkt @@ -4,11 +4,15 @@ [asm-string (-> (listof instruction?) string?)] ; deprecated [asm-display (-> (listof instruction?) any)]) +(define current-os + (make-parameter (system-type 'os))) + (define current-shared? (make-parameter #f)) (module* private #f - (provide current-shared?)) + (provide current-shared?) + (provide current-os)) ;; Asm -> String (define (asm-string a) @@ -26,14 +30,12 @@ ;; Label -> String ;; prefix with _ for Mac -(define label-symbol->string - (match (system-type 'os) +(define (label-symbol->string s) + (match (current-os) ['macosx - (λ (s) - (string-append "_" (symbol->string s)))] + (string-append "\"_" (symbol->string s) "\"")] [_ - (λ (s) - (symbol->string s))])) + (string-append "\"" (symbol->string s) "\"")])) ;(if (and (current-shared?) (memq s (current-extern-labels))) ; hack for ELF64 shared libraries in service of @@ -41,14 +43,7 @@ ;(string-append "$" (symbol->string s) " wrt ..plt") ;(symbol->string s)))])) -(define extern-label-decl-symbol->string - (match (system-type 'os) - ['macosx - (λ (s) - (string-append "_" (symbol->string s)))] - [_ - (λ (s) - (symbol->string s))])) +(define extern-label-decl-symbol->string label-symbol->string) ;; Instruction -> String (define (common-instruction->string i) @@ -187,12 +182,12 @@ (string-append "(" (exp->string e1) " " (symbol->string o) " " (exp->string e2) ")")])) (define (text-section n) - (match (system-type 'os) - ['macosx (format ".section __TEXT,~a\n\t.p2align 4" n)] + (match (current-os) + ['macosx (format ".section __TEXT,~a" n)] [_ (format ".section ~a,\"ax\",@progbits\n\t.p2align 4" n)])) (define (data-section n) - (match (system-type 'os) + (match (current-os) ['macosx (format ".section __DATA,~a\n\t.p2align 3" n)] [_ (format ".section ~a,\"aw\",@progbits\n\t.p2align 3" n)])) @@ -207,7 +202,7 @@ [(Global ($ l)) (string-append tab ".global " (label-symbol->string l))] [(Label ($ l)) (string-append (label-symbol->string l) ":")] [(Align n) - (match (system-type 'os) + (match (current-os) ['macosx (string-append ".p2align " (number->string (let loop ([i 0] [n n]) From b72bff1c7841b6a04afb676dd22fb44989314a3f Mon Sep 17 00:00:00 2001 From: David Van Horn Date: Wed, 8 Apr 2026 21:40:23 -0400 Subject: [PATCH 2/2] Remove Racket package caching which seems to cache a86, which we definitely don't want. --- .github/workflows/push.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 614fc88..dd1dc68 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -33,16 +33,6 @@ jobs: clang --version gcc --version - - name: Cache Racket packages - uses: actions/cache@v4 - with: - path: | - ~/.racket - ~/.cache/racket - ~/.local/share/racket - ~/Library/Caches/Racket - key: racket-${{ matrix.racket-variant }}-${{ matrix.racket-version }}-${{ matrix.os }} - - name: Install a86 package run: | raco pkg install --no-docs ../a86/