From 3656e8c81784007543eca741717805df6f163168 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Tue, 14 Dec 2021 13:03:58 +0000 Subject: [PATCH] restore cross compile build --- start.sh | 7 +++++++ util/build.c | 48 ++++++++++++++---------------------------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/start.sh b/start.sh index e729ee9..7afa1c3 100755 --- a/start.sh +++ b/start.sh @@ -61,6 +61,13 @@ if [ $? -ne 0 ]; then exit fi +# Check make is available. +make --version > /dev/null +if [ $? -ne 0 ]; then + echo "Error: Missing make." + exit +fi + # Compile and run Build. gcc -o bin/build -g util/build.c -pthread -DPARALLEL_BUILD -D${ES_TARGET-TARGET_X86_64} \ -Wall -Wextra -Wno-format-security -Wno-format-overflow -Wno-missing-field-initializers -Wno-unused-function -Wno-format-truncation \ diff --git a/util/build.c b/util/build.c index 2d65b1d..5ee2139 100644 --- a/util/build.c +++ b/util/build.c @@ -589,42 +589,9 @@ void BuildCrossCompiler() { exit(0); } - bool usePreBuilt; - { printf("\n"); - printf("To build Essence, you need a cross compiler.\n"); -#ifdef __linux__ - printf("You can either use a pre-built cross compiler (~40MB download), or build one locally.\n"); - printf("Type 'yes' if you want to use the pre-built cross compiler.\n"); - usePreBuilt = automatedBuild || GetYes(); -#else - printf("A cross compiler will be built for you automatically.\n"); -#endif - } - - if (usePreBuilt) { - DoCommand("get-source prefix https://github.com/nakst/build-gcc-x86_64-essence/releases/download/gcc-v11.1.0/out.tar.xz"); - if (CallSystem("mv bin/source cross")) goto fail; - if (CallSystem("mkdir -p cross/bin2")) goto fail; - foundValidCrossCompiler = true; - getcwd(compilerPath, sizeof(compilerPath)); - strcat(compilerPath, "/cross/bin2"); - if (CallSystem("gcc -o bin/change_sysroot util/change_sysroot.c -Wall -Wextra")) goto fail; -#define MAKE_TOOLCHAIN_WRAPPER(tool) \ - if (CallSystem("gcc -o cross/bin2/" TOOLCHAIN_PREFIX "-" tool " util/toolchain_wrapper.c -Wall -Wextra -g -DTOOL=" TOOLCHAIN_PREFIX "-" tool)) goto fail; - MAKE_TOOLCHAIN_WRAPPER("ar"); - MAKE_TOOLCHAIN_WRAPPER("gcc"); - MAKE_TOOLCHAIN_WRAPPER("g++"); - MAKE_TOOLCHAIN_WRAPPER("ld"); - MAKE_TOOLCHAIN_WRAPPER("nm"); - MAKE_TOOLCHAIN_WRAPPER("strip"); - if (!AddCompilerToPath()) goto fail; - SaveConfig(); - return; - } - - { + printf("To build Essence, you need a cross compiler. This will be built for you automatically.\n"); printf("- You need to be connected to the internet. ~100MB will be downloaded.\n"); printf("- You need ~3GB of drive space available.\n"); printf("- You need ~8GB of RAM available.\n"); @@ -1602,6 +1569,19 @@ void DoCommand(const char *l) { getcwd(cwd, sizeof(cwd)); strcat(cwd, "/crash-report.tar.gz"); fprintf(stderr, "Crash report made at " ColorHighlight "%s" ColorNormal ".\n", cwd); + } else if (0 == strcmp(l, "setup-pre-built-toolchain")) { + if (CallSystem("mv bin/source cross")) goto fail; + if (CallSystem("mkdir -p cross/bin2")) goto fail; + if (CallSystem("gcc -o bin/change_sysroot util/change_sysroot.c -Wall -Wextra")) goto fail; +#define MAKE_TOOLCHAIN_WRAPPER(tool) \ + if (CallSystem("gcc -o cross/bin2/" TOOLCHAIN_PREFIX "-" tool " util/toolchain_wrapper.c -Wall -Wextra -g -DTOOL=" TOOLCHAIN_PREFIX "-" tool)) goto fail; + MAKE_TOOLCHAIN_WRAPPER("ar"); + MAKE_TOOLCHAIN_WRAPPER("gcc"); + MAKE_TOOLCHAIN_WRAPPER("g++"); + MAKE_TOOLCHAIN_WRAPPER("ld"); + MAKE_TOOLCHAIN_WRAPPER("nm"); + MAKE_TOOLCHAIN_WRAPPER("strip"); + SaveConfig(); } else if (0 == strcmp(l, "help") || 0 == strcmp(l, "h") || 0 == strcmp(l, "?")) { printf(ColorHighlight "\n=== Common Commands ===\n" ColorNormal); printf("build (b) - Build.\n");