-DCMAKE_BUILD_TYPE=Release breaks build process

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

-DCMAKE_BUILD_TYPE=Release breaks build process

Bernhard Seckinger
Hi all,

I'm relatively new to cmake and tried to use it for one of my projects.
Meanwhile I've got a working version, but when I try to build with
-DCMAKE_BUILD_TYPE=Release the linker complains about missing functions.

I guess, that this happens, because all the files are compiled separately and
-O3 removes some functions (or inlines them or whatever). When I compile
manually using -O3, everything works, but in that case I do compilation of
all files and linking in one stroke.

I'm using cmake-d (1), a cmake extension to compile D-files. On my computer
(debian, testing) cmake chooses gdc for compilation which is a D-frontend to
gcc.

I'm quite unsure how I should proceed to make it work. Although I read various
tutorials and stuff about cmake I still feel not like having understood,
what's going on behind the scenes. (What I'm missing is something like the
autotools-guide (2) for cmake.)

Maybe you can give me some ideas on how to proceed?

Berni

PS: And of course, if anyone would like to have a direct look at my
project and give some comments on it, I'd be really happy. You can find it at
github (3).

PPS: I asked a similar question in the D-Forum, but got no answers there,
probably because it's the wrong place to do so...

(1) https://github.com/dcarp/cmake-d
(2)
http://freesoftwaremagazine.com/articles/autotools_a_guide_to_autoconf_automake_libtool/
(3) https://github.com/crocopaw/croco/tree/devel

--
-- Meine Rätselwebseite: www.croco-puzzle.com

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

🐋 Jan Hegewald
Hi Berni,

> On 2 Mar 2017, at 10:12, Bernhard Seckinger <[hidden email]> wrote:
...
> but when I try to build with
> -DCMAKE_BUILD_TYPE=Release the linker complains about missing functions.
...
> Maybe you can give me some ideas on how to proceed?
...

just a general idea as how to approach this:
- make a clean cmake directory and try again, or at least remove the CMakeCache.txt
- if you use the make generator, add -DCMAKE_VERBOSE_MAKEFILE=ON when calling cmake to know what exactly is being used during build

HTH,
Jan Hegewald

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

Konstantin Tokarev


02.03.2017, 13:58, "🐋 Jan Hegewald" <[hidden email]>:

> Hi Berni,
>
>>  On 2 Mar 2017, at 10:12, Bernhard Seckinger <[hidden email]> wrote:
>
> ...
>>  but when I try to build with
>>  -DCMAKE_BUILD_TYPE=Release the linker complains about missing functions.
>
> ...
>>  Maybe you can give me some ideas on how to proceed?
>
> ...
>
> just a general idea as how to approach this:
> - make a clean cmake directory and try again, or at least remove the CMakeCache.txt
> - if you use the make generator, add -DCMAKE_VERBOSE_MAKEFILE=ON when calling cmake to know what exactly is being used during build

This is not a good advice, better don't touch CMAKE_VERBOSE_MAKEFILE and use make VERBOSE=1 whenever you want to see details

>
> HTH,
> Jan Hegewald
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake

--
Regards,
Konstantin
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

Bernhard Seckinger
In reply to this post by 🐋 Jan Hegewald
Hi Jan,

> just a general idea as how to approach this:
> - make a clean cmake directory and try again, or at least remove the
> CMakeCache.txt

I'm allready doing this all the time... :-)

> - if you use the make generator, add -DCMAKE_VERBOSE_MAKEFILE=ON when
> calling cmake to know what exactly is being used during build

Basically it's (works)

/usr/bin/gdc  -I.. -fversion=slang  -oCMakeFiles/starbattle.dir/__/puzzle
-c /home/berni/Croco/Entwicklung/Croco/types/puzzle.d
[...]
/usr/bin/gdc     CMakeFiles/starbattle.dir/starbattle
CMakeFiles/starbattle.dir/starbattle_check_puzzle
CMakeFiles/starbattle.dir/starbattle_check_solution
CMakeFiles/starbattle.dir/__/puzzle
CMakeFiles/starbattle.dir/__/puzzle_options
CMakeFiles/starbattle.dir/__/puzzle_unittest
CMakeFiles/starbattle.dir/__/spf_tools CMakeFiles/starbattle.dir/__/puzzle_io
CMakeFiles/starbattle.dir/__/puzzle_timer CMakeFiles/starbattle.dir/__/slang
-ostarbattle  -L/usr/lib/gcc/x86_64-linux-gnu/6 ../libslang_wrapper.o.a
-lslang -lc  

vs. (does not work)

/usr/bin/gdc  -O3 -fomit-frame-pointer -fweb -frelease -finline-functions
-I.. -fversion=slang  -oCMakeFiles/starbattle.dir/__/puzzle
-c /home/berni/Croco/Entwicklung/Croco/types/puzzle.d
[...]
/usr/bin/gdc  -O3 -fomit-frame-pointer -fweb -frelease -finline-functions
CMakeFiles/starbattle.dir/starbattle
CMakeFiles/starbattle.dir/starbattle_check_puzzle
CMakeFiles/starbattle.dir/starbattle_check_solution
CMakeFiles/starbattle.dir/__/puzzle
CMakeFiles/starbattle.dir/__/puzzle_options
CMakeFiles/starbattle.dir/__/puzzle_unittest
CMakeFiles/starbattle.dir/__/spf_tools CMakeFiles/starbattle.dir/__/puzzle_io
CMakeFiles/starbattle.dir/__/puzzle_timer CMakeFiles/starbattle.dir/__/slang
-ostarbattle  -L/usr/lib/gcc/x86_64-linux-gnu/6 ../libslang_wrapper.o.a
-lslang -lc  

One can even remove "-fomit-frame-pointer -fweb -frelease -finline-functions"
and set -O1 instead of -O3 to get the same result.

And that's the output of the last call:

CMakeFiles/starbattle.dir/starbattle_check_puzzle: In function
`_DT256_D25starbattle_check_solution25Starbattle_Check_Solution16extract_solutionMFHAyaAyaZv':
starbattle_check_puzzle.d:
(.text._DT256_D25starbattle_check_solution25Starbattle_Check_Solution16extract_solutionMFHAyaAyaZv
[_DT256_D25starbattle_check_solution25Starbattle_Check_Solution16extract_solutionMFHAyaAyaZv]
+0x8e): undefined reference to
`_D25starbattle_check_solution25Starbattle_Check_Solution16extract_solutionMFHAyaAyaZ12__dgliteral2MFNaNbNiNfZAxa'
CMakeFiles/starbattle.dir/starbattle_check_puzzle: In function
`_DT256_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv':
starbattle_check_puzzle.d:
(.text._DT256_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv
[_DT256_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv]+0x12): undefined
reference to
`_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZ12__dgliteral2MFNaNbNiNfZAya'
starbattle_check_puzzle.d:
(.text._DT256_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv
[_DT256_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv]+0xbd): undefined
reference to
`_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZ12__dgliteral3MFNaNbNiNfZAya'
CMakeFiles/starbattle.dir/starbattle_check_solution: In function
`_DT96_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv':
starbattle_check_solution.d:
(.text._DT96_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv
[_DT96_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv]+0xf): undefined
reference to
`_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZ12__dgliteral2MFNaNbNiNfZAya'
starbattle_check_solution.d:
(.text._DT96_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv
[_DT96_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZv]+0xba): undefined
reference to
`_D10starbattle10Starbattle14extract_puzzleMFHAyaAyaZ12__dgliteral3MFNaNbNiNfZAya'
collect2: error: ld returned 1 exit status

Berni

--
-- Meine Rätselwebseite: www.croco-puzzle.com

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

Alan W. Irwin
On 2017-03-02 13:01+0100 Bernhard Seckinger wrote:

> Basically it's (works)
>
> /usr/bin/gdc  -I.. -fversion=slang  -oCMakeFiles/starbattle.dir/__/puzzle
> -c /home/berni/Croco/Entwicklung/Croco/types/puzzle.d
> [...]
> /usr/bin/gdc     CMakeFiles/starbattle.dir/starbattle
> CMakeFiles/starbattle.dir/starbattle_check_puzzle
> CMakeFiles/starbattle.dir/starbattle_check_solution
> CMakeFiles/starbattle.dir/__/puzzle
> CMakeFiles/starbattle.dir/__/puzzle_options
> CMakeFiles/starbattle.dir/__/puzzle_unittest
> CMakeFiles/starbattle.dir/__/spf_tools CMakeFiles/starbattle.dir/__/puzzle_io
> CMakeFiles/starbattle.dir/__/puzzle_timer CMakeFiles/starbattle.dir/__/slang
> -ostarbattle  -L/usr/lib/gcc/x86_64-linux-gnu/6 ../libslang_wrapper.o.a
> -lslang -lc
>
> vs. (does not work)
>
> /usr/bin/gdc  -O3 -fomit-frame-pointer -fweb -frelease -finline-functions
> -I.. -fversion=slang  -oCMakeFiles/starbattle.dir/__/puzzle
> -c /home/berni/Croco/Entwicklung/Croco/types/puzzle.d
> [...]
> /usr/bin/gdc  -O3 -fomit-frame-pointer -fweb -frelease -finline-functions
> CMakeFiles/starbattle.dir/starbattle
> CMakeFiles/starbattle.dir/starbattle_check_puzzle
> CMakeFiles/starbattle.dir/starbattle_check_solution
> CMakeFiles/starbattle.dir/__/puzzle
> CMakeFiles/starbattle.dir/__/puzzle_options
> CMakeFiles/starbattle.dir/__/puzzle_unittest
> CMakeFiles/starbattle.dir/__/spf_tools CMakeFiles/starbattle.dir/__/puzzle_io
> CMakeFiles/starbattle.dir/__/puzzle_timer CMakeFiles/starbattle.dir/__/slang
> -ostarbattle  -L/usr/lib/gcc/x86_64-linux-gnu/6 ../libslang_wrapper.o.a
> -lslang -lc
>
> One can even remove "-fomit-frame-pointer -fweb -frelease -finline-functions"
> and set -O1 instead of -O3 to get the same result.

Hi Bernhard:

The problem is that CMake has no native support for gdc so several
external projects have supplied that support.  For example, PLplot
(the project I am associated with) obtained our CMake support for gdc
from CMakeD (by Selman Ulug and Tim Burrell) a decade ago, and we have
been tweaking it ever since for just our own needs, but we have no
interest in supporting CMakeD for others because the strong impression
I have is that project has been superseded by other projects which we
intend to move to eventually once we have evaluated them.

It appears you are using https://github.com/dcarp/cmake-d for CMake
gdc support which as far as I can tell (e.g., from the license which
does not mention Ulug or Burrel) is completely different from CMakeD.
Anyhow, you should contact the authors of cmake-d with your bug report
and/or try other modern possibilities revealed by, say, a google
search for the terms <cmake gdc>.

My advice for putting together that bug report is to create the
simplest standalone example of the problem that is possible (e.g.,
consiting of a CMakeLists.txt file that builds and installs a "hello,
world" D application + D language source code for that application.

Then after configuring that simple test project with
-DCMAKE_BUILD_TYPE=Release, run "make VERBOSE=1" which tells you
exactly the commands that were executed which lead to the linking
error.  Afterward replicate that last (gdc)
command that generated the linker error by hand, and then start
changing (by hand) the gdc options until you isolate the one that is
causing the linker issue.

Assuming you isolate the issue that way, then you have demonstrated a
bug in your particular CMake support for gdc for the
-DCMAKE_BUILD_TYPE=Release case which you should report to the authors
of your CMake gdc support.  That simple self-contained example will be
a big help to them in replicating the issue and figuring it out.  And
if they are not responsive to your bug report, perhaps it is time to
move to some other CMake gdc support project which is more responsive
or which does not have the issue with -DCMAKE_BUILD_TYPE=Release that
you have found with the cmake-d project.

Good luck, and I would appreciate you sharing with me (and possibly
this list) how it goes since I am interested in trying something
different from a tweaked CMakeD for gdc language support in
the CMake-based PLplot build system.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

Bernhard Seckinger
> My advice for putting together that bug report is to create the
> simplest standalone example of the problem that is possible (e.g.,
> consiting of a CMakeLists.txt file that builds and installs a "hello,
> world" D application + D language source code for that application.

After one mornings work I've got such a small example. And surprisingly it's a
bug in gdc and has nothing to do with neither cmake nor cmake-d. I filed a bug
report for gdc. :-)

Thanks for your help.

Berni

--
-- Meine Rätselwebseite: www.croco-puzzle.com

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: -DCMAKE_BUILD_TYPE=Release breaks build process

Alan W. Irwin
On 2017-03-03 16:14+0100 Bernhard Seckinger wrote:

>> My advice for putting together that bug report is to create the
>> simplest standalone example of the problem that is possible (e.g.,
>> consiting of a CMakeLists.txt file that builds and installs a "hello,
>> world" D application + D language source code for that application.
>
> After one mornings work I've got such a small example. And surprisingly it's a
> bug in gdc and has nothing to do with neither cmake nor cmake-d. I filed a bug
> report for gdc. :-)
>
> Thanks for your help.

Hi Berni:

You are welcome.

And for the others here, Berni's general result (making a simple
example of what appear to be CMake problems often yields important new
insights) is quite typical with CMake in my experience.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...