最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

csh - How to capture both the printed screen logs and output into a log file when using `armclang` in a Makefile? - Stack Overfl

programmeradmin1浏览0评论

I'm trying to capture the printed screen logs into a log file when using armclang in a Makefile.

Makefile:

all: startup_armclang startup_armasm main_armclang

startup_armclang:
    armclang --target=arm-arm-none-eabi -march=armv7-r -DBL1 _DRAM_JUMP -E -x assembler-with-cpp ./startup.s > temp.s

startup_armasm:
    armasm --diag_style=gnu --brief_diagnostics -g --debug --keep --cpu=Cortex-R5 -I. -I./System -o startup.o temp.s
    rm -f temp.s

main_armclang:
    armclang -c --target=arm-arm-none-eabi -marm -march=armv7-r -mcpu=cortex-r5 -g1 --debug -O0 -fno-function-sections -fno-data-sections -mfloat-abi=soft -mfpu=none -I. -I./System Main.c -o Main.o -MMD -MF Main.d

I tried :

  1. $>make all > log

    make: Warning: File Makefile has modification time 4.1e+02 s in the future armclang: warning: Avoid specifying both the architecture (-march) and the processor (-mcpu) because specifying both has the potential to cause a conflict. The compiler infers the correct architecture from the processor. [-Wunused-command-line-argument] Main.c:605:56: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mCtrMode, ~~~~~~~~~~~~~~~~~~~~~~~~^~~~ Main.c:606:56: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mInstBuff, ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ Main.c:607:84: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mFlashAddr[CoreType][ImgType], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ Main.c:608:37: warning: expression result unused [-Wunused-value] (UINT8 *)(ptBootInfo->tHeader[CoreType][ImgType]), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ Main.c:609:55: error: extraneous ')' before ';' BL_IMG_HEADER_SIZE); ^ Main.c:609:37: warning: expression result unused [-Wunused-value]

But only logged as the below log:

armclang --target=arm-arm-none-eabi -march=armv7-r -DBL1 _DRAM_JUMP -E -x assembler-with-cpp ./startup.s > ./temp.s
armasm --diag_style=gnu --brief_diagnostics -g --debug -keep --cpu=Cortex-R5 -I . -I./System -o ./startup.o temp.s
rm -f temp.s
armclang -c --target=arm-arm-none-eabi -marm -march=armv7-r -mcpu=cortex-r5 -g1 --debug -O0 --fno-function-sections --fno-data-sections -mfloat-abi=soft -mfpu=none -I . -I./System Main.c -o Main.o -MMD -MF Main.d
  1. $>make all 2>&1 | tee log But this make Error message as 'Ambiguous output redirect'.

I'm trying to capture the printed screen logs into a log file when using armclang in a Makefile.

Makefile:

all: startup_armclang startup_armasm main_armclang

startup_armclang:
    armclang --target=arm-arm-none-eabi -march=armv7-r -DBL1 _DRAM_JUMP -E -x assembler-with-cpp ./startup.s > temp.s

startup_armasm:
    armasm --diag_style=gnu --brief_diagnostics -g --debug --keep --cpu=Cortex-R5 -I. -I./System -o startup.o temp.s
    rm -f temp.s

main_armclang:
    armclang -c --target=arm-arm-none-eabi -marm -march=armv7-r -mcpu=cortex-r5 -g1 --debug -O0 -fno-function-sections -fno-data-sections -mfloat-abi=soft -mfpu=none -I. -I./System Main.c -o Main.o -MMD -MF Main.d

I tried :

  1. $>make all > log

    make: Warning: File Makefile has modification time 4.1e+02 s in the future armclang: warning: Avoid specifying both the architecture (-march) and the processor (-mcpu) because specifying both has the potential to cause a conflict. The compiler infers the correct architecture from the processor. [-Wunused-command-line-argument] Main.c:605:56: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mCtrMode, ~~~~~~~~~~~~~~~~~~~~~~~~^~~~ Main.c:606:56: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mInstBuff, ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ Main.c:607:84: warning: expression result unused [-Wunused-value] ptBootInfo->tImage.mFlashAddr[CoreType][ImgType], ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ Main.c:608:37: warning: expression result unused [-Wunused-value] (UINT8 *)(ptBootInfo->tHeader[CoreType][ImgType]), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ Main.c:609:55: error: extraneous ')' before ';' BL_IMG_HEADER_SIZE); ^ Main.c:609:37: warning: expression result unused [-Wunused-value]

But only logged as the below log:

armclang --target=arm-arm-none-eabi -march=armv7-r -DBL1 _DRAM_JUMP -E -x assembler-with-cpp ./startup.s > ./temp.s
armasm --diag_style=gnu --brief_diagnostics -g --debug -keep --cpu=Cortex-R5 -I . -I./System -o ./startup.o temp.s
rm -f temp.s
armclang -c --target=arm-arm-none-eabi -marm -march=armv7-r -mcpu=cortex-r5 -g1 --debug -O0 --fno-function-sections --fno-data-sections -mfloat-abi=soft -mfpu=none -I . -I./System Main.c -o Main.o -MMD -MF Main.d
  1. $>make all 2>&1 | tee log But this make Error message as 'Ambiguous output redirect'.
Share Improve this question edited Mar 19 at 10:41 Carter asked Mar 19 at 0:58 CarterCarter 2863 silver badges17 bronze badges 3
  • Do not present images of text. Instead, copy & paste the text itself into the question. – John Bollinger Commented Mar 19 at 5:24
  • And, please format the output properly as a code block so it's readable. – MadScientist Commented Mar 19 at 14:43
  • I thought csh/tcsh had been relegated to the trashbin of history. Please, stop using it. You will feel better. – MadScientist Commented Mar 19 at 14:45
Add a comment  | 

1 Answer 1

Reset to default 1

I have to hand a small C project built with a GNU Makefile and I have introduced #error Whoops into one of the source files. My default shell is:

$ echo $SHELL
/bin/bash

My sabotaged project (fails to) build like:

$ make
cc    -c -o bar_init.o bar_init.c
cc    -c -o default_opt_init.o default_opt_init.c
cc    -c -o foo_init.o foo_init.c
cc    -c -o init.o init.c
cc    -c -o main.o main.c
main.c:3:2: error: #error Whoops
    3 | #error Whoops
      |  ^~~~~
make: *** [<builtin>: main.o] Error 1

I can log the standard output and standard error while still sending them to console in just the way you attempted:

$ make 2>&1 | tee log
cc    -c -o bar_init.o bar_init.c
cc    -c -o default_opt_init.o default_opt_init.c
cc    -c -o foo_init.o foo_init.c
cc    -c -o init.o init.c
cc    -c -o main.o main.c
main.c:3:2: error: #error Whoops
    3 | #error Whoops
      |  ^~~~~
make: *** [<builtin>: main.o] Error 1

$ cat log
cc    -c -o bar_init.o bar_init.c
cc    -c -o default_opt_init.o default_opt_init.c
cc    -c -o foo_init.o foo_init.c
cc    -c -o init.o init.c
cc    -c -o main.o main.c
main.c:3:2: error: #error Whoops
    3 | #error Whoops
      |  ^~~~~
make: *** [<builtin>: main.o] Error 1

So it works in bash. You are using the csh shell. I also have the tcsh shell, which has the same redirection facilities as csh:

$ tcsh
> make clean
rm -f prog *.o
> make 2>&1 | tee log
Ambiguous output redirect.
> make 2 > & 1 |

As you see, shell redirection syntax is not the same in [t]csh and bash.

[t]csh redirection facilities are less convenient than those of bash. To achieve what you want in [t]csh you need to do:

> make clean
rm -f prog *.o
> make |& cat | tee log
cc    -c -o bar_init.o bar_init.c
cc    -c -o default_opt_init.o default_opt_init.c
cc    -c -o foo_init.o foo_init.c
cc    -c -o init.o init.c
cc    -c -o main.o main.c
main.c:3:2: error: #error Whoops
    3 | #error Whoops
      |  ^~~~~
make: *** [<builtin>: main.o] Error 1

> cat log
cc    -c -o bar_init.o bar_init.c
cc    -c -o default_opt_init.o default_opt_init.c
cc    -c -o foo_init.o foo_init.c
cc    -c -o init.o init.c
cc    -c -o main.o main.c
main.c:3:2: error: #error Whoops
    3 | #error Whoops
      |  ^~~~~
make: *** [<builtin>: main.o] Error 1
发布评论

评论列表(0)

  1. 暂无评论