Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit 1ee339b

Browse files
committed
container-apps: pre_build_insn
1 parent 2c1d15c commit 1ee339b

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

scripts/container-apps-functions-source.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@ function build_gcc_first()
280280
CPPFLAGS="${XBB_CPPFLAGS}"
281281
# The gcc/emit_insn.c is huge (>62 MB), so give up on using -pipe
282282
# and multiple sections, in order to save memory.
283-
CFLAGS="$(echo "${XBB_CFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
284-
CXXFLAGS="$(echo "${XBB_CXXFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
283+
# CFLAGS="$(echo "${XBB_CFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
284+
# CXXFLAGS="$(echo "${XBB_CXXFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
285+
CFLAGS="${XBB_CFLAGS_NO_W}"
286+
CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
285287
LDFLAGS="${XBB_LDFLAGS_APP}"
286288
if [ "${TARGET_PLATFORM}" == "linux" ]
287289
then
@@ -376,6 +378,9 @@ function build_gcc_first()
376378
echo
377379
echo "Running gcc first stage make..."
378380

381+
# Pre-cook the very large files.
382+
pre_build_insn
383+
379384
# Build.
380385
# No need to make 'all', 'all-gcc' is enough to compile the libraries.
381386
run_verbose make -j ${JOBS} all-gcc
@@ -394,6 +399,31 @@ function build_gcc_first()
394399
fi
395400
}
396401

402+
function pre_build_insn()
403+
{
404+
(
405+
cd gcc
406+
407+
# The gcc/emit_insn.c is huge (>62 MB), so give up on using -pipe
408+
# and multiple sections, in order to save memory.
409+
410+
cp Makefile Makefile-patched
411+
sed -i.bak \
412+
-e 's|-ffunction-sections||' \
413+
-e 's|-fdata-sections||' \
414+
-e 's|-pipe||' \
415+
Makefile-patched
416+
417+
for file_name in insn-*.c
418+
do
419+
target=$(echo ${file_name} | sed -e 's|\.c|\.o|')
420+
421+
# Build the huge files separately, without parallel build.
422+
run_verbose make -j 1 -f Makefile-patched ${target}
423+
done
424+
)
425+
}
426+
397427
# For the nano build, call it with "-nano".
398428
# $1="" or $1="-nano"
399429
function build_newlib()
@@ -759,8 +789,10 @@ function build_gcc_final()
759789

760790
# The gcc/emit_insn.c is huge (>62 MB), so give up on using -pipe
761791
# and multiple sections, in order to save memory.
762-
CFLAGS="$(echo "${XBB_CFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
763-
CXXFLAGS="$(echo "${XBB_CXXFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
792+
# CFLAGS="$(echo "${XBB_CFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
793+
# CXXFLAGS="$(echo "${XBB_CXXFLAGS_NO_W}" | sed -e 's|-ffunction-sections||' | sed -e 's|-fdata-sections||' | sed -e 's|-pipe||')"
794+
CFLAGS="${XBB_CFLAGS_NO_W}"
795+
CXXFLAGS="${XBB_CXXFLAGS_NO_W}"
764796

765797
# Attempts to use `-Wa,-mbig-obj` failed on Windows.
766798

@@ -932,6 +964,9 @@ function build_gcc_final()
932964
echo
933965
echo "Running gcc$1 final stage make..."
934966

967+
# Pre-cook the very large files.
968+
pre_build_insn
969+
935970
if [ "${TARGET_PLATFORM}" != "win32" ]
936971
then
937972

0 commit comments

Comments
 (0)