Discussion:
unwanted added compiler arguments
Arthur Gruzauskas
2017-10-29 03:26:29 UTC
Permalink
Hi List,

Started playing with using C++17 features, but have hit a wall with some unwanted
compiler arguments being magically appended.

It boils down to " -fPIC -std=c++14" somehow being appended to the end of my
compiler command arguments.

Now, I'm quite happy with -fPIC, but the -std=c++14 overrides my -std=c++1z
argument.

Looking through every configuration dialog in KDevelop didn't help.

Looking through the various CMake files in the build directory, i can't see this added
anywhere.

Using gcc instead of clang shows the same added args.

Google has not been my friend.

Is there somewhere that kdevelop adds "-fPIC -std=c++14" ?

Arthur

I'm using KDevelop 5.1.80 from git.

The compile line that shows those added arguments (in red):

/usr/bin/clang++-4.0 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -
DQT_WIDGETS_LIB -isystem /usr/include/x86_64-linux-gnu/qt5 -I. -I/home/artg/
alocal/ajg_stuff -I/usr/local/cuda/include -isystem /usr/include/x86_64-linux-gnu/qt5/
QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/
x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g+
+-64 -march=native -std=c++1z -pipe -Wall -Werror -Wshadow -Wno-c++98-compat
-Weverything -Wno-conversion -Wno-sign-compare -Wno-c++98-compat-pedantic -
Wno-padded -Wno-documentation-unknown-command -Wno-deprecated -Wno-
covered-switch-default -Wno-exit-time-destructors -Wno-global-constructors -Wno-
disabled-macro-expansion -O3 -DNDEBUG *-fPIC -std=c++14* -MD -MT
CMakeFiles/weathered.dir/src/world.cpp.o -MF CMakeFiles/weathered.dir/src/
world.cpp.o.d -o CMakeFiles/weathered.dir/src/world.cpp.o -c ../src/world.cpp
Sven Brauch
2017-10-30 11:16:20 UTC
Permalink
Post by Arthur Gruzauskas
Started playing with using C++17 features, but have hit a wall with some unwanted
compiler arguments being magically appended.
What build system do you use? Did you also tell your build system to
also use C++17? KDevelop retrieves arguments from there.

Greetings,
Sven
Arthur Gruzauskas
2017-10-30 12:28:44 UTC
Permalink
Post by Sven Brauch
Post by Arthur Gruzauskas
Started playing with using C++17 features, but have hit a wall with some
unwanted compiler arguments being magically appended.
What build system do you use? Did you also tell your build system to
also use C++17? KDevelop retrieves arguments from there.
Greetings,
Sven
My build system is CMake, in the Open Configuration... dialog I simply accept the
default values for all CMake variables, only setting CMAKE_BUILD_TYPE to Release


In CMakeLists.txt I set:

set(CMAKE_CXX_COMPILER "/usr/bin/clang++-4.0")

# see https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS "-march=native -std=c++1z -pipe -Wall -Werror -Wshadow -
Wno-c++98-compat -Weverything -Wno-conversion -Wno-sign-compare -Wno-c+
+98-compat-pedantic -Wno-padded -Wno-documentation-unknown-command -
Wno-deprecated -Wno-covered-switch-default -Wno-exit-time-destructors -Wno-
global-constructors -Wno-disabled-macro-expansion")


in ~/.bashrc, /etc/bash.bashrc and CMakeLists.txt , a file text search shows no
reference to 'PIC' nor 'c++14' . Ditto in the Open Configuration.. -> Configure
Language Support dialog.

clang & gcc are standard debian testing installs with no modifications.

I have repeatedly removed the whole build directory, used gcc instead, to no avail.

In the compiler build panel, the "-fPIC -std=c++14" looks to be appended to my
CMAKE_CXX_FLAGS above, as shown in the original post.

Is this a KDevelop thing, or should I be looking elsewhere?

Arthur, a bit embarrassed to be bringing up something no one else is having a
problem with.
Aleix Pol
2017-10-30 12:48:24 UTC
Permalink
Post by Sven Brauch
Post by Arthur Gruzauskas
Started playing with using C++17 features, but have hit a wall with some
unwanted compiler arguments being magically appended.
What build system do you use? Did you also tell your build system to
also use C++17? KDevelop retrieves arguments from there.
Greetings,
Sven
My build system is CMake, in the Open Configuration... dialog I simply
accept the default values for all CMake variables, only setting
CMAKE_BUILD_TYPE to Release
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-4.0")
# see https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "-march=native -std=c++1z -pipe -Wall -Werror -Wshadow
-Wno-c++98-compat -Weverything -Wno-conversion -Wno-sign-compare
-Wno-c++98-compat-pedantic -Wno-padded -Wno-documentation-unknown-command
-Wno-deprecated -Wno-covered-switch-default -Wno-exit-time-destructors
-Wno-global-constructors -Wno-disabled-macro-expansion")
in ~/.bashrc, /etc/bash.bashrc and CMakeLists.txt , a file text search shows
no reference to 'PIC' nor 'c++14' . Ditto in the Open Configuration.. ->
Configure Language Support dialog.
clang & gcc are standard debian testing installs with no modifications.
I have repeatedly removed the whole build directory, used gcc instead, to no avail.
In the compiler build panel, the "-fPIC -std=c++14" looks to be appended to
my CMAKE_CXX_FLAGS above, as shown in the original post.
Is this a KDevelop thing, or should I be looking elsewhere?
Arthur, a bit embarrassed to be bringing up something no one else is having
a problem with.
It seems logical to me that c++14 is passed if you specify
"set(CMAKE_CXX_STANDARD 14)".

It's something between you and cmake anyway. KDevelop has little to do there.

Aleix
René J.V. Bertin
2017-10-30 13:06:46 UTC
Permalink
Post by Aleix Pol
It seems logical to me that c++14 is passed if you specify
"set(CMAKE_CXX_STANDARD 14)".
My thoughts exactly.

CMake has a habit of appending its arguments after any you set yourself, unless you target the appropriate variables for the build type you've chosen.
Or unless you select a custom build type, like Debian and Ubuntu do (or used to do? CMAKE_BUILD_TYPE=Debian). But I guess that even in that case arguments to come from settings like the one above will get appended (and that would actually make sense).

R.
Arthur Gruzauskas
2017-10-30 13:27:13 UTC
Permalink
Thanks Guys.

Using "set(CMAKE_CXX_STANDARD 14)" solved some issue I had awhile back,
forgotten what. BTW setting it to 17 produces a whole swag of errors I would
rather leave for a super brain day.

Removing
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

now it appends "-fPIC -std=gnu++11" to my build panel command line...

So not a KDevelop issue, I'll stop bothering you.

And I now have somewhere else to fiddle with this puzzle. CMake exploring, here
I come!

Arthur, who appreciates your quick and useful help
Post by René J.V. Bertin
Post by Aleix Pol
It seems logical to me that c++14 is passed if you specify
"set(CMAKE_CXX_STANDARD 14)".
My thoughts exactly.
CMake has a habit of appending its arguments after any you set yourself,
unless you target the appropriate variables for the build type you've
chosen. Or unless you select a custom build type, like Debian and Ubuntu do
(or used to do? CMAKE_BUILD_TYPE=Debian). But I guess that even in that
case arguments to come from settings like the one above will get appended
(and that would actually make sense).
R.
Sven Brauch
2017-10-30 13:46:58 UTC
Permalink
Post by Arthur Gruzauskas
now it appends "-fPIC -std=gnu++11" to my build panel command line...
Yeah, because now the C++ mode for cmake is C++11 ;)
I think cmake_cxx_standard=17 does not work yet? Try appending
-std=c++17 to CMAKE_CXX_FLAGS in CMakeLists.txt.
Arthur Gruzauskas
2017-10-31 03:57:27 UTC
Permalink
Post by Sven Brauch
Post by Arthur Gruzauskas
now it appends "-fPIC -std=gnu++11" to my build panel command line...
Yeah, because now the C++ mode for cmake is C++11 ;)
I think cmake_cxx_standard=17 does not work yet? Try appending
-std=c++17 to CMAKE_CXX_FLAGS in CMakeLists.txt.
either -std=c++1z or -std=c++17 in CMAKE_CXX_FLAGS seems acceptable, but then
both are overridden by the appended "-fPIC -std=gnu++11" on the end by CMake.

Including:
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

the appended stuff on the build line becomes "-fPIC -std=c++14"

changing to:
set(CMAKE_CXX_STANDARD 17)

the appended stuff on the build line becomes "-fPIC -std=c++1z"

So, KDevelop and CMake are doing the right thing after all !!!

Unfortunately that causes miscompiles within #include <string>, which is the
first line in a source file...

So, this problem does not belong on this list. Thank you for helping me see I
need to look elsewhere.

Arthur, who will be playing with a basic new project to troubleshoot this
issue, happy to have pruned a large chunk off the problem tree.

Alexander Shaduri
2017-10-30 12:51:34 UTC
Permalink
Hi,

It probably comes from one of the libraries you use, like Qt.
(I remember Qt >= 5.7 enabling C++11 by default, maybe it defaults
to the latest stable C++ your compiler supports?)

Cheers,
Alexander
Post by Arthur Gruzauskas
 
Post by Sven Brauch
Post by Arthur Gruzauskas
Started playing with using C++17 features, but have hit a wall
with some
Post by Sven Brauch
Post by Arthur Gruzauskas
unwanted compiler arguments being magically appended.
 
What build system do you use? Did you also tell your build system
to
Post by Sven Brauch
also use C++17? KDevelop retrieves arguments from there.
 
Greetings,
Sven
 
 
 My build system is CMake, in the Open Configuration...  dialog I
simply accept the default values for all CMake variables, only
setting CMAKE_BUILD_TYPE to Release
 
 
 
set(CMAKE_CXX_COMPILER "/usr/bin/clang++-4.0")
 
# see https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
 
set(CMAKE_CXX_FLAGS "-march=native -std=c++1z -pipe -Wall -Werror
-Wshadow -Wno-c++98-compat -Weverything -Wno-conversion -Wno-sign-
compare -Wno-c++98-compat-pedantic -Wno-padded -Wno-documentation-
unknown-command -Wno-deprecated -Wno-covered-switch-default -Wno-
exit-time-destructors -Wno-global-constructors -Wno-disabled-macro-
expansion") 
 
 
in ~/.bashrc, /etc/bash.bashrc and CMakeLists.txt , a file text
search shows no reference to 'PIC' nor 'c++14' . Ditto in the Open
Configuration.. -> Configure Language Support dialog.
 
clang & gcc are standard debian testing installs with no
modifications.
 
I have repeatedly removed the whole build directory, used gcc
instead, to no avail.
 
In the compiler build panel, the "-fPIC -std=c++14" looks to be
appended to my CMAKE_CXX_FLAGS above, as shown in the original post.
 
Is this a KDevelop thing, or should I be looking elsewhere?
 
Arthur, a bit embarrassed to be bringing up something no one else is
having a problem with.
Loading...