From 7d6e2fc89bfaf032cae9f95f5bbb276ff06d9c69 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 27 Jul 2019 07:47:37 -0600 Subject: [PATCH] cs: fix launcher hack for cross build Disable optimizations that would avoid inspecting literal string data that is modified in the run-time executable. --- racket/src/start/start.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/racket/src/start/start.c b/racket/src/start/start.c index 7e00019e64..03dd7b2f14 100644 --- a/racket/src/start/start.c +++ b/racket/src/start/start.c @@ -41,10 +41,17 @@ #endif #define DUPLICATE_INPUT +#if defined(__GNUC__) +# define PRESERVE_IN_EXECUTABLE __attribute__((used)) +#else +# define PRESERVE_IN_EXECUTABLE /* empty */ +#endif + /* Win command lines limited to 1024 chars, so 1024 chars for command tail is ample */ -static wchar_t *input = +PRESERVE_IN_EXECUTABLE +wchar_t * volatile input = L""; -static wchar_t *variant = L""; +PRESERVE_IN_EXECUTABLE +wchar_t * volatile variant = L""; static int wc_strlen(const wchar_t *ws) { @@ -279,6 +288,7 @@ int wmain(int argc_in, wchar_t **argv_in) /* gcc: input is read-only */ input = copy_string(input); exedir = copy_string(exedir); + variant = copy_string(variant); #endif count = 1;