Skip to content

Commit 7ad329f

Browse files
authored
Use alternate method to inject COMPILER_ARGS for N64 EGCS compilers (#1709)
* Use alternate method to inject COMPILER_ARGS for N64 EGCS compilers * golf * gpt feedback * handle empty flags * Move COMPILER_FLAGS after the hardcoded flags
1 parent 6f36c5a commit 7ad329f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

backend/coreapp/compilers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,16 +930,25 @@ def available_platforms() -> List[Platform]:
930930
'&& python3 "${COMPILER_DIR}"/modern-asn64.py mips-linux-gnu-as "$OUTPUT".s -G0 -EB -mtune=vr4300 -march=vr4300 -mabi=32 -O1 --no-construct-floats -o "$OUTPUT"',
931931
)
932932

933+
# Python alternative to the printf/xargs approach for quoted flags
934+
PYTHON_SHLEX = """[[ -n "${COMPILER_FLAGS}" ]] && mapfile -t FLAGS < <(python3 -c "import shlex,sys; print(*shlex.split(sys.argv[1]), sep='\\n')" "${COMPILER_FLAGS}"); """
935+
933936
EGCS1124 = GCCCompiler(
934937
id="egcs_1.1.2-4",
935938
platform=N64,
936-
cc='printf "%s" "${COMPILER_FLAGS}" | COMPILER_PATH="${COMPILER_DIR}" xargs -- "${COMPILER_DIR}"/mips-linux-gcc -c -G 0 -fno-PIC -mgp32 -mfp32 -mcpu=4300 -nostdinc "${INPUT}" -o "${OUTPUT}"',
939+
cc=(
940+
PYTHON_SHLEX
941+
+ 'COMPILER_PATH="${COMPILER_DIR}" "${COMPILER_DIR}/mips-linux-gcc" -c -G 0 -fno-PIC -mgp32 -mfp32 -mcpu=4300 -nostdinc "${FLAGS[@]}" "${INPUT}" -o "${OUTPUT}"'
942+
),
937943
)
938944

939945
EGCS1124C = GCCCompiler(
940946
id="egcs_1.1.2-4c",
941947
platform=N64,
942-
cc='printf "%s" "${COMPILER_FLAGS}" | COMPILER_PATH="${COMPILER_DIR}" xargs -- "${COMPILER_DIR}"/gcc -c -G 0 -fno-PIC -mgp32 -mfp32 -mcpu=4300 -nostdinc "${INPUT}" -o "${OUTPUT}"',
948+
cc=(
949+
PYTHON_SHLEX
950+
+ 'COMPILER_PATH="${COMPILER_DIR}" "${COMPILER_DIR}/gcc" -c -G 0 -fno-PIC -mgp32 -mfp32 -mcpu=4300 -nostdinc "${FLAGS[@]}" "${INPUT}" -o "${OUTPUT}"'
951+
),
943952
)
944953

945954
GCC440MIPS64ELF = GCCCompiler(

0 commit comments

Comments
 (0)