Wind River Support Network

HomeDefectsLIN7-5981
Fixed

LIN7-5981 : compile with -imacros, __FILE__ will not expand correctly

Created: Apr 20, 2016    Updated: Sep 8, 2018
Resolved Date: May 31, 2016
Found In Version: 7.0.0.14
Fix Version: 7.0.0.17
Severity: Standard
Applicable for: Wind River Linux 7
Component/s: Toolchain

Description

Customer use wrlinux6 RCPL 16 cav_octeon3 BSP.
Their project configured with the following options:
wrlinux-6/wrlinux/configure --enable-multilib=lib32 --enable-board=cav_octeon3 --enable-build=production --enable-kernel=standard --enable-rootfs=glibc_small --with-template=feature/initramfs,feature/build_libc --enable-jobs=16 --enable-parallel-pkgbuilds=16 --with-rcpl-version=0016

They found a bug in SDK toolchain.
if compile with -imacros, the __FILE__ macro is not be expanded correctly.

Here is a simple way to reproduce it:
---------------
# echo "int main() { return }" > foo.c
# touch foo.h
# mips64_n32_octeon3-target-linux-gnu-gcc -imacros foo.h foo.c 
<command-line>: In function 'main':
<command-line>:1:21: error: expected expression before '}' token
----------------

With a x86 gcc, it can be correctly expanded:
------------------
xxxx@xxxxxxx:/build/xxxx/testapp$ echo "int main() { return }" > foo.c
xxxx@xxxxxxx:/build/xxxx/testapp$ touch foo.h
xxxx@xxxxxxx:/build/xxxx/testapp$ gcc -imacros foo.h foo.c
foo.c: In function 'main':
foo.c:1:21: error: expected expression before '}' token
-------------------

I can reproduce this issue in my side.
And I also checked if use -imacros, the preprocessed source code is not correct, __FILE__ is expanded to command-line.

Steps to Reproduce

# echo "int main() { return }" > foo.c
# touch foo.h
# mips64_n32_octeon3-target-linux-gnu-gcc -imacros foo.h foo.c 
<command-line>: In function 'main':
<command-line>:1:21: error: expected expression before '}' token

Other Downloads


Live chat
Online