Menu

#2267 Forcing -fPIC creates spurious warning output

OTHER
closed
nobody
None
Support
wont-fix
Behaves_as_Documented
False
2017-02-13
2015-07-31
No

Forcing a compile with -fPIC creates a load of spurious warning information. For some reason, it regurgitates the frist couple lines of every file:

$ make CXXFLAGS="-DNDEBUG -g2 -O2 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe"
WARNING: CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined in config.h
g++ -DNDEBUG -g2 -O2 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c 3way.cpp
3way.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 // 3way.cpp - modifed by Wei Dai from Joan Daemen's 3way.c
 ^
g++ -DNDEBUG -g2 -O2 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c adler32.cpp
adler32.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 // adler32.cpp - written and placed in the public domain by Wei Dai
 ^

We have to force fPIC because we are experiencing a crash when automatic PIC is used (i.e., if we omit -fPIC, PIC is still used but we get the crash).

Discussion

  • Jeffrey Walton

    Jeffrey Walton - 2015-07-31
    $ g++ -v
    Using built-in specs.
    COLLECT_GCC=C:\MinGW\bin\g++.exe
    COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
    Target: mingw32
    Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m
    ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
    --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++
    ,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l
    ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
    p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --
    with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-
    libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/
    mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
    Thread model: win32
    gcc version 4.8.1 (GCC)
    
    $ uname -a
    MINGW32_NT-6.1 WINDOWS-7-X64 1.0.18(0.48/3/2) 2012-11-21 22:34 i686 Msys
    
     
  • Keith Marshall

    Keith Marshall - 2015-08-02

    -fPIC is supposed to have no effect in WIN32 builds; thus, it seems rather mysterious that

    We have to force fPIC because we are experiencing a crash when automatic PIC is used (i.e., if we omit -fPIC, PIC is still used but we get the crash).

    will mitigate your crash. If you can identify why this may be so, when it really should not be, then that may merit discussion upstream, on GCC's BugZilla; (using -fPIC in WIN32 appears to induce a side effect, which it is not supposed to).

    In view of the supposed nil-effect of -fPIC on WIN32, I am inclined to support the GCC maintainer's stance that the warning is warranted; (to borrow an allegory from audio electronics, -fPIC is noise at the input stage which is amplified, to become the warning at the output stage). Nonetheless, if you disagree, feel free to "raise your own standard" on the same GCC BugZilla. From a MinGW perspective, this will likely become a "won't fix" issue.

     
  • Keith Marshall

    Keith Marshall - 2015-08-02
    • status: unread --> open
     
  • Keith Marshall

    Keith Marshall - 2017-02-13
    • status: open --> closed
    • Resolution: none --> wont-fix
    • Category: Unknown --> Behaves_as_Documented