mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-15 07:19:18 +00:00
tool/cosmocc: Do not run fixupobj for text output (#1084)
Some compiler flags (such as -E or -MM) instruct GCC to only run the preprocessor and produce certain text files. In this case, we do not want to run `fixupobj` and make the tool fail because the input is not an ELF64 binary.
This commit is contained in:
parent
6715b670b1
commit
a2753de7fd
2 changed files with 36 additions and 11 deletions
|
@ -100,6 +100,7 @@ INTENT=ld
|
|||
GOT_SOME=0
|
||||
NEED_OUTPUT=
|
||||
RELOCATABLE=0
|
||||
OUTPUT_IS_TEXT=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
|
@ -175,6 +176,12 @@ for x; do
|
|||
GOT_SOME=1
|
||||
elif [ x"$x" = x"-dumpmachine" ]; then
|
||||
GOT_SOME=1
|
||||
elif [ x"$x" = x"-M" ] ||
|
||||
[ x"$x" = x"-MM" ] ||
|
||||
[ x"$x" = x"-MD" ] ||
|
||||
[ x"$x" = x"-MMD" ] ||
|
||||
[ x"$x" = x"-E" ]; then
|
||||
OUTPUT_IS_TEXT=1
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
@ -216,7 +223,10 @@ log_command "$@"
|
|||
|
||||
if [ -n "$OUTPUT" ] && [ -f "$OUTPUT" ]; then
|
||||
if [ $INTENT = cc ] || [ $INTENT = ld ]; then
|
||||
"$BIN/fixupobj" "$OUTPUT" || exit
|
||||
if [ $OUTPUT_IS_TEXT -eq 0 ]; then
|
||||
"$BIN/fixupobj" "$OUTPUT"
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
if [ $INTENT = ld ]; then
|
||||
if [ x"$OUTPUT" != x"${OUTPUT%.com}" ] ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue