From 5db75a92ae6321b6c98fd29bce30bd6fd5e3f7ec Mon Sep 17 00:00:00 2001 From: Paulo Matos Date: Wed, 30 Sep 2020 15:44:13 +0200 Subject: [PATCH] Small fixes to enable LTO compilation (#3418) Small fixes to enable LTO compilation To do this in racket/src: ./configure CFLAGS="-O3 -march=native -flto" LDFLAGS="-O3 -march=native -flto" --prefix=... One fix deals with variable `errnum` that might be used uninitialized. The other is to ensure that `boot_file_data` is marked as used otherwise, it is removed by LTO and ends up crashing build in `embed-boot.rkt`. --- racket/src/ChezScheme/c/new-io.c | 6 +++--- racket/src/cs/c/main.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/racket/src/ChezScheme/c/new-io.c b/racket/src/ChezScheme/c/new-io.c index eb03c1ec79..d131a36f21 100644 --- a/racket/src/ChezScheme/c/new-io.c +++ b/racket/src/ChezScheme/c/new-io.c @@ -78,7 +78,7 @@ static int is_valid_lz4_length(iptr count); do { body; \ if (ok) { flag = 0; } \ else { \ - INT errnum; \ + INT errnum = 0; \ S_glzerror((fd),&errnum); \ S_glzclearerr((fd)); \ if (errnum == Z_ERRNO) { \ @@ -99,7 +99,7 @@ static int is_valid_lz4_length(iptr count); do { body; \ if (ok) { flag = 0; break; } \ else { \ - INT errnum; \ + INT errnum = 0; \ S_glzerror((fd),&errnum); \ S_glzclearerr((fd)); \ if (errnum == Z_ERRNO) { \ @@ -117,7 +117,7 @@ static int is_valid_lz4_length(iptr count); do { body; \ if (ok) { flag = 0; } \ else { \ - INT errnum; \ + INT errnum = 0; \ S_glzerror((fd),&errnum); \ S_glzclearerr((fd)); \ if (errnum == Z_ERRNO) { flag = 1; } \ diff --git a/racket/src/cs/c/main.c b/racket/src/cs/c/main.c index 5cb3515a64..8e81eb1afb 100644 --- a/racket/src/cs/c/main.c +++ b/racket/src/cs/c/main.c @@ -53,6 +53,7 @@ static void scheme_set_dll_procs(scheme_dll_open_proc open, # define embedded_dll_close NULL #endif +PRESERVE_IN_EXECUTABLE char *boot_file_data = "BooT FilE OffsetS:\0\0\0\0\0\0\0\0\0\0\0\0"; static int boot_file_offset = 18;