| Summary: | Long-standing build output gcc-version spam on Cygwin host | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Chris Renshaw <osm0sis> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | trivial | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: |
gcc-version.sh patch for the reported issue
New gcc-version.sh patch for the issue. Final patch for the gcc-version.sh |
||
NAK. Investigate what happens when echo __GNUC__ __GNUC_MINOR__ | gcc -E -xc - is run. Chris@Homebase ~ $ echo __GNUC__ __GNUC_MINOR__ | gcc -E -xc - # 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 1 "<stdin>" 9 3 Chris@Homebase ~ $ So would echo -n or printf work, to omit the trailing newline? echo -n __GNUC__ __GNUC_MINOR__ | cc -E -xc - | tail -n 1 printf "__GNUC__ __GNUC_MINOR__" | cc -E -xc - | tail -n 1 Just adding
| grep .
to that pipe to filter out empty lines should fix it. Can you confirm?
Chris@Homebase ~ $ echo -n __GNUC__ __GNUC_MINOR__ | gcc -E -xc - | tail -n 1 9 3 Chris@Homebase ~ $ printf "__GNUC__ __GNUC_MINOR__" | gcc -E -xc - | tail -n 1 9 3 Chris@Homebase ~ $ echo __GNUC__ __GNUC_MINOR__ | gcc -E -xc - | grep . # 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 1 "<stdin>" 9 3 Chris@Homebase ~ $ I meant this: --- a/scripts/gcc-version.sh +++ b/scripts/gcc-version.sh @@ -8,5 +8,5 @@ compiler="$*" -MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) +MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | grep . | tail -n 1) printf '%02d%02d\n' $MAJ_MIN Hmm, looks the same output from command-line.. I'll try actually patching the file and running a compile. Chris@Homebase ~ $ compiler=gcc Chris@Homebase ~ $ MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) Chris@Homebase ~ $ printf '%02d%02d\n' $MAJ_MIN 0903 Chris@Homebase ~ $ MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | grep . | tail -n 1) Chris@Homebase ~ $ printf '%02d%02d\n' $MAJ_MIN 0903 Chris@Homebase ~ $ Unfortunately still broken with your committed patch, so I'm reopening: : invalid numberbox-1.32.1/scripts/gcc-version.sh: line 12: printf: 9 HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/split-include HOSTCC scripts/basic/docproc HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o HOSTCC scripts/kconfig/mconf.o HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf -s Config.in # # using defaults found in .config # : invalid numberbox-1.32.1/scripts/gcc-version.sh: line 12: printf: 9 SPLIT include/autoconf.h -> include/config/* make: *** [Makefile:858: include/config/MARKER] Interrupt I added this to gcc_version.sh to tease out the issue more, and turns out it's the NDK gcc which is being weird:
echo "$compiler:$MAJ_MIN:" >> ~/compiler.log
And from compiler.log, it is indeed a newline causing the issue:
/home/Chris/x-tools/i686-linux-android-r15c-api21-unified/bin/i686-linux-android-gcc:4 9
:
Running it directly:
$ scripts/gcc-version.sh /home/Chris/x-tools/i686-linux-android-r15c-api21-unified/bin/i686-linux-android-gcc
: invalid numberion.sh: line 12: printf: 9
0409
It doesn't look broken compared to any of the output we've looked at, but somehow the MAJ_MIN= captures a newline:
Chris@Homebase ~/busybox-1.32.1
$ echo $compiler
/home/Chris/x-tools/i686-linux-android-r15c-api21-unified/bin/i686-linux-android-gcc
Chris@Homebase ~/busybox-1.32.1
$ echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1
4 9
Even just trying to echo $MAJ_MIN on the command line gives some weird results... the trailing : should display somewhere, but doesn't:
Chris@Homebase ~/busybox-1.32.1
$ MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
Chris@Homebase ~/busybox-1.32.1
$ echo ":${MAJ_MIN}:"
:4 9
And it gets weirder:
Chris@Homebase ~/busybox-1.32.1
$ echo ":$MAJ_MIN"
:4 9
Chris@Homebase ~/busybox-1.32.1
$ echo ":$MAJ_MIN:"
:4 9
Chris@Homebase ~/busybox-1.32.1
$ echo ":$MAJ_MIN::"
:: 9
Chris@Homebase ~/busybox-1.32.1
$ echo ":$MAJ_MIN:::"
:::9
Chris@Homebase ~/busybox-1.32.1
$ echo ":$MAJ_MIN::::"
::::
I guess gcc_version.sh still having the correct output is why I landed on 2>/dev/null as the fix back when I made the submitted patch.
Ah, I examined the output in a hex editor, it's not a LF causing the issure, it's a CR! grep . didn't help because a CR is treated like text I guess? Adding a new patch to resolve it properly by stripping the CR. If you use it, please maintain authorship, since I noticed you didn't for the wait3 or warning array subscript patches. Created attachment 8906 [details]
New gcc-version.sh patch for the issue.
So, $((echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)) produced the string "4 9\r" ?! My God :) $ patch -p1 </tmp/000-gcc-version.patch --dry-run checking file scripts/gcc-version.sh Hunk #1 FAILED at 9. 1 out of 1 hunk FAILED Also, please add "Signed-off-by: Chris Renshaw <osm0sis@outlook.com>" line to the patch. Our git is set up to require signoff. (In reply to Denys Vlasenko from comment #12) that's why i tried to suggest echo -n or printf in the hopes to get rid of any CRNL ;) Yeah, crazy right? Thanks! I wasn't accounting for you adding the `grep .` to master in my updated patch. I'll rebase at HEAD and add the Signed-off line. Created attachment 8911 [details]
Final patch for the gcc-version.sh
Applied, thanks |
Created attachment 8861 [details] gcc-version.sh patch for the reported issue This shows up multiple times during build with Cygwin host : invalid numberbox-1.32.1/scripts/gcc-version.sh: line 12: printf: 9 Appears to be some slight difference in gcc output causing it, but doesn't actually then seem to have any effect on the build as far as I can tell. Regardless, here's a minor patch to resolve it.