[Development] Qt-5.1, qglobal.h and PIC detection
Hi, I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). Is it possible to use CLang 3.2 with Qt 5.1 on Linux, or do I need to use amore recent verion of CLang or maybe wait for Qt 5.2? Any hint appreciated, Chris # Clang version on Ubunutu 13.04: $ clang --version Ubuntu clang version 3.2-1~exp9ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2) Target: i386-pc-linux-gnu Thread model: posix # No PIC macros defined by CLang: $ clang -dM -E -x c /dev/null |grep -i 'PIC\|PIE\|ELF' #define __ELF__ 1 The build log: [...] /usr/share/clang/scan-build/c++-analyzer -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DUTILS_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -I/opt/lambda/2013.10/5.1.1/gcc/mkspecs/linux-g++ -I. -I/opt/lambda/2013.10/5.1.1/gcc/include -I/opt/lambda/2013.10/5.1.1/gcc/include/QtXml -I/opt/lambda/2013.10/5.1.1/gcc/include/QtCore -I. -o fileutils.o fileutils.cpp In file included from qtcassert.cpp:30: In file included from ./qtcassert.h:33: In file included from ./utils_global.h:4: /opt/lambda/2013.10/5.1.1/gcc/include/QtCore/qglobal.h:975:4: error: You must build your code with position independent code if Qt was built with -reduce-relocations. Compile your code with -fPIC or -fPIE. # error You must build your code with position independent code if Qt was built with -reduce-relocations. \ ^ 1 error generated. [...] And in qglobal.h:975 #if !defined(QT_BOOTSTRAPPED) defined(QT_REDUCE_RELOCATIONS) defined(__ELF__) !defined(__PIC__) !defined(__PIE__) # error You must build your code with position independent code if Qt was built with -reduce-relocations. \ Compile your code with -fPIC or -fPIE. #endif ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] Qt-5.1, qglobal.h and PIC detection
On Wednesday 06 November 2013 12:17:56 Christian Gagneraud wrote: Hi, I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). Is it possible to use CLang 3.2 with Qt 5.1 on Linux, or do I need to use amore recent verion of CLang or maybe wait for Qt 5.2? Simply add -fPIC or -fPIE. clang -fPIE -dM -E -x c /dev/null |grep -i 'PIC\|PIE\|ELF' #define __ELF__ 1 #define __PIC__ 2 #define __PIE__ 2 #define __pic__ 2 #define __pie__ 2 -- Olivier Woboq - Qt services and support - http://woboq.com - http://code.woboq.org ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] Qt-5.1, qglobal.h and PIC detection
On quarta-feira, 6 de novembro de 2013 12:17:56, Christian Gagneraud wrote: I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). Yes it does. linux $ diff -U0 (clang -xc++ -dM -E /dev/null) (clang -fPIC -xc++ -dM -E /dev/null) --- /proc/self/fd/112013-11-05 15:25:03.872215425 -0800 +++ /proc/self/fd/122013-11-05 15:25:03.872215425 -0800 @@ -103,0 +104 @@ +#define __PIC__ 2 @@ -156,0 +158 @@ +#define __pic__ 2 mac $ diff -U0 (clang -xc++ -dM -E /dev/null) (clang -fPIC -xc++ -dM -E /dev/null) --- /dev/fd/11 2013-11-05 15:25:49.0 -0800 +++ /dev/fd/12 2013-11-05 15:25:49.0 -0800 @@ -90 +90 @@ -#define __PIC__ 1 +#define __PIC__ 2 @@ -143 +143 @@ -#define __pic__ 1 +#define __pic__ 2 -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center signature.asc Description: This is a digitally signed message part. ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] Qt-5.1, qglobal.h and PIC detection
On Wednesday 06 November 2013 12:17:56 Christian Gagneraud wrote: Hi, I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). ... That's a bug in scan-build script, already fixed in clang upstream. More details in https://bugreports.qt-project.org/browse/QTBUG-33698 Regards, Liang -- http://www.qiliang.net ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development
Re: [Development] Qt-5.1, qglobal.h and PIC detection
On 06/11/13 12:25, Olivier Goffart wrote: On Wednesday 06 November 2013 12:17:56 Christian Gagneraud wrote: Hi, I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). Is it possible to use CLang 3.2 with Qt 5.1 on Linux, or do I need to use amore recent verion of CLang or maybe wait for Qt 5.2? Simply add -fPIC or -fPIE. clang -fPIE -dM -E -x c /dev/null |grep -i 'PIC\|PIE\|ELF' #define __ELF__ 1 #define __PIC__ 2 #define __PIE__ 2 #define __pic__ 2 #define __pie__ 2 Good point, it works here as well, but I still have the error when building my code, scan-build replace the calls to g++ by clang++ (using CXX=clamg++), but the -fPIC get lost somewhere... To get it working, I have to do: $ scan-build 'make CC=${CC} CXX=${CXX}' So maybe, i'm not using it correctly While debugging, here is the output of scan-build: $ scan-build -v -v -v 'make CC=${CC} CXX=${CXX}' scan-build: Using '/usr/bin/clang' for static analysis scan-build: Emitting reports for this run to '/tmp/scan-build-2013-11-06-7'. /usr/share/clang/scan-build/c++-analyzer -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DUTILS_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -I/opt/lambda/2013.10/5.1.1/gcc/mkspecs/linux-g++ -I. -I/opt/lambda/2013.10/5.1.1/gcc/include -I/opt/lambda/2013.10/5.1.1/gcc/include/QtXml -I/opt/lambda/2013.10/5.1.1/gcc/include/QtCore -I. -o fileutils.o fileutils.cpp g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DUTILS_LIBRARY -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -I/opt/lambda/2013.10/5.1.1/gcc/mkspecs/linux-g++ -I. -I/opt/lambda/2013.10/5.1.1/gcc/include -I/opt/lambda/2013.10/5.1.1/gcc/include/QtXml -I/opt/lambda/2013.10/5.1.1/gcc/include/QtCore -I. -o fileutils.o fileutils.cpp [LOCATION]: /home/christiaga/projects/lambda-simulator/utils #SHELL (cd '/home/christiaga/projects/lambda-simulator/utils' '/usr/bin/clang++' '-cc1' '-triple' 'i386-pc-linux-gnu' '-analyze' '-disable-free' '-disable-llvm-verifier' '-main-file-name' 'fileutils.cpp' '-analyzer-store=region' '-analyzer-opt-analyze-nested-blocks' '-analyzer-eagerly-assume' '-analyzer-checker=core' '-analyzer-checker=unix' '-analyzer-checker=deadcode' '-analyzer-checker=security.insecureAPI.UncheckedReturn' '-analyzer-checker=security.insecureAPI.getpw' '-analyzer-checker=security.insecureAPI.gets' '-analyzer-checker=security.insecureAPI.mktemp' '-analyzer-checker=security.insecureAPI.mkstemp' '-analyzer-checker=security.insecureAPI.vfork' '-analyzer-output' 'plist' '-w' '-mrelocation-model' 'static' '-mdisable-fp-elim' '-fmath-errno' '-masm-verbose' '-mconstructor-aliases' '-fuse-init-array' '-target-cpu' 'pentium4' '-target-linker-version' '2.23.2' '-momit-leaf-frame-pointer' '-resource-dir' '/usr/bin/../lib/clang/3.2' '-D' '_REENTRANT' '-D' 'UTILS_LIBRARY' '-D' 'QT_NO_DEBUG' '-D' 'QT_XML_LIB' '-D' 'QT_CORE_LIB' '-I' '/opt/lambda/2013.10/5.1.1/gcc/mkspecs/linux-g++' '-I' '.' '-I' '/opt/lambda/2013.10/5.1.1/gcc/include' '-I' '/opt/lambda/2013.10/5.1.1/gcc/include/QtXml' '-I' '/opt/lambda/2013.10/5.1.1/gcc/include/QtCore' '-I' '.' '-fmodule-cache-path' '/var/tmp/clang-module-cache' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7/i686-linux-gnu' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/4.7/backward' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/i386-linux-gnu/c++/4.7' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/i386-linux-gnu/c++/4.7/i686-linux-gnu' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/i386-linux-gnu/c++/4.7/backward' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/i686-linux-gnu' '-internal-isystem' '/usr/bin/../lib/gcc/i686-linux-gnu/4.7/../../../../include/c++/backward' '-internal-isystem' '/usr/local/include' '-internal-isystem' '/usr/bin/../lib/clang/3.2/include' '-internal-isystem' '/usr/include/clang/3.2/include/' '-internal-externc-isystem' '/usr/include/i386-linux-gnu' '-internal-externc-isystem' '/usr/include/i686-linux-gnu' '-internal-externc-isystem' '/usr/include' '-fdeprecated-macro' '-fdebug-compilation-dir' '/home/christiaga/projects/lambda-simulator/utils' '-ferror-limit' '19' '-fmessage-length' '0' '-mstackrealign' '-fobjc-runtime=gcc' '-fcxx-exceptions' '-fexceptions' '-fdiagnostics-show-option' '-analyzer-display-progress' '-analyzer-output=html' '-o' '/tmp/scan-build-2013-11-06-7' '-x' 'c++' 'fileutils.cpp') In file included from
Re: [Development] Qt-5.1, qglobal.h and PIC detection
On 06/11/13 13:19, Liang Qi wrote: On Wednesday 06 November 2013 12:17:56 Christian Gagneraud wrote: Hi, I'm using CLang build-analize tool, and when I switched from Qt 4.8 to Qt 5.1 (insalled from Qt project's download area), I got a Qt #error, basically the code is built with -fPIC, but CLang doesn't define a PIC macro, so the build fails due to a check in qglobal.h (see details below). ... That's a bug in scan-build script, already fixed in clang upstream. More details in https://bugreports.qt-project.org/browse/QTBUG-33698 Thanks Liang! Chris Regards, Liang -- http://www.qiliang.net ___ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development