Skip to content

Commit

Permalink
ios: constrain recent allocation segments generation, fix for tarm64-…
Browse files Browse the repository at this point in the history
…>tarm64 cross-compilation

Includes new `force-host-out?' arg to `compile-to-file'.
When the host and target machines match during
"cross"-compilation (eg. M1 Mac to iOS), we still need to generate
host .so files so that the build works out.
  • Loading branch information
Bogdanp authored Jan 18, 2021
1 parent 764b552 commit 6b0b3e0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
3 changes: 0 additions & 3 deletions racket/src/ChezScheme/c/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ void S_close_off_thread_local_segment(ptr tc, ISPC s, IGEN g) {
close_off_segment(tgc, tgc->next_loc[g][s], tgc->base_loc[g][s], tgc->sweep_loc[g][s], s, g);

tgc->base_loc[g][s] = (ptr)0;
#if defined(WRITE_XOR_EXECUTE_CODE)
tgc->base_loc[g][s] = 0;
#endif
tgc->bytes_left[g][s] = 0;
tgc->next_loc[g][s] = (ptr)0;
tgc->sweep_loc[g][s] = (ptr)0;
Expand Down
10 changes: 6 additions & 4 deletions racket/src/ChezScheme/c/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,12 @@ static void enable_code_write(ptr tc, IGEN maxg, IBOOL on, IBOOL current, void *
if (!on) {
while ((sip = tgc->sweep_next[0][space_code]) != NULL) {
tgc->sweep_next[0][space_code] = sip->sweep_next;
addr = sip->sweep_start;
bytes = sip->sweep_bytes;
if (mprotect(addr, bytes, flags) != 0) {
S_error_abort("failed to protect recent allocation segments");
if (sip->generation == 0) {
addr = sip->sweep_start;
bytes = sip->sweep_bytes;
if (mprotect(addr, bytes, flags) != 0) {
S_error_abort("failed to protect recent allocation segments");
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions racket/src/ChezScheme/c/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ptr S_create_thread_object(who, p_tc) const char *who; ptr p_tc; {
tgc->next_loc[g][s] = (ptr)0;
tgc->bytes_left[g][s] = 0;
tgc->sweep_loc[g][s] = (ptr)0;
tgc->sweep_next[g][s] = NULL;
}
tgc->bitmask_overhead[g] = 0;
}
Expand Down
1 change: 1 addition & 0 deletions racket/src/ChezScheme/mats/primvars.ms
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
[(list-of-symbols) '(a b c) '("a") #f]
[(maybe-binary-output-port) *binary-output-port *binary-input-port (current-output-port)]
[(maybe-char) #\a 0]
[(maybe-force-host-out?) #t 0]
[(maybe-pathname) "a" 'a]
[(maybe-procedure) values 0]
[(maybe-rtd) *rtd *record ""]
Expand Down
9 changes: 6 additions & 3 deletions racket/src/ChezScheme/s/compile.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2227,17 +2227,20 @@
(set-who! compile-to-file
(rec compile-to-file
(case-lambda
[(sexpr* out) (compile-to-file sexpr* out #f)]
[(sexpr* out sfd)
[(sexpr* out) (compile-to-file sexpr* out #f #f)]
[(sexpr* out sfd) (compile-to-file sexpr* out sfd #f)]
[(sexpr* out sfd force-host-out?)
(unless (list? sexpr*) ($oops who "~s is not a proper list" sexpr*))
(unless (string? out) ($oops who "~s is not a string" out))
(when sfd (unless (source-file-descriptor? sfd) ($oops who "~s is not a source-file descriptor or #f" sfd)))
(unless (boolean? force-host-out?) ($oops who "~s is not a boolean" force-host-out?))
(let ([library? (and (= (length sexpr*) 1) (pair? (car sexpr*)) (eq? (caar sexpr*) 'library))]
[program? (and (= (length sexpr*) 1) (pair? (car sexpr*)) (eq? (caar sexpr*) 'top-level-program))])
(define (go)
(do-compile-to-file who out
(and library?
(not (eq? (constant machine-type-name) (machine-type)))
(or force-host-out?
(not (eq? (constant machine-type-name) (machine-type))))
(format "~a.~s" (path-root out) (machine-type)))
(constant machine-type-name)
sfd
Expand Down
2 changes: 1 addition & 1 deletion racket/src/ChezScheme/s/primdata.ss
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@
(compile-script [sig [(pathname) (pathname pathname) (pathname pathname sub-symbol) -> (void)]] [flags true])
(compile-time-value? [sig [(ptr) -> (boolean)]] [flags pure unrestricted mifoldable discard])
(compile-time-value-value [sig [(compile-time-value) -> (ptr)]] [flags pure mifoldable discard])
(compile-to-file [sig [(list pathname) (list pathname maybe-sfd) -> (void/list)]] [flags true])
(compile-to-file [sig [(list pathname) (list pathname maybe-sfd) (list pathname maybe-sfd maybe-force-host-out?) -> (void/list)]] [flags true])
(compile-to-port [sig [(list binary-output-port) (list binary-output-port maybe-sfd) (list binary-output-port maybe-sfd maybe-binary-output-port) (list binary-output-port maybe-sfd maybe-binary-output-port maybe-textual-output-port) (list binary-output-port maybe-sfd maybe-binary-output-port maybe-textual-output-port sub-symbol) (list binary-output-port maybe-sfd maybe-binary-output-port maybe-textual-output-port sub-symbol maybe-binary-output-port) (list binary-output-port maybe-sfd maybe-binary-output-port maybe-textual-output-port sub-symbol maybe-binary-output-port ptr) (list binary-output-port maybe-sfd maybe-binary-output-port maybe-textual-output-port sub-symbol maybe-binary-output-port ptr ptr) -> (void/list)]] [flags true])
(compile-whole-program [sig [(string string) (string string ptr) -> (void)]] [flags])
(compile-whole-library [sig [(string string) -> (void)]] [flags])
Expand Down
3 changes: 2 additions & 1 deletion racket/src/cs/compile-file.ss
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
(let ([e (map annotation-expression
(annotation-expression e))])
(cons e (loop pos))))))))])
(compile-to-file exprs dest)))]
;; Pass #t for `force-host-out?' in case host and target are the same.
(compile-to-file exprs dest #f #t)))]
[else
;; Normal mode
(compile-file src dest)]))]))
Expand Down

0 comments on commit 6b0b3e0

Please sign in to comment.