English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 09 February 2020, 22:08   #1
iliak
Registered User
 
Join Date: Jan 2008
Location: somewhere
Posts: 45
VBCC, CLion and CMake sample project

Hi

I'm looking for a (simple) CMake project using VBCC and (ideally with) CLion. I'm stuck at moving from gcc to vbcc in my CMakeFile.

I have to tricks CLion with a nice "set(CMAKE_C_COMPILER_WORKS TRUE)" in the CMakeLists.txt, but I have the nice following error :

Code:
Compiler exited with error code 1: /opt/vbcc/bin/vc -xc +aos68k ~/dev/kernel_amiga/rom/libraries/exec/io/CreateIORequest.c -I~/dev/kernel_amiga/rom/includes -fpch-preprocess -v -dD -E
Thanks !

Iliak
iliak is offline  
Old 10 February 2020, 10:29   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
I have neither experience with CMake nor with CLion, but did you try to execute the command in a shell to find out why it fails? It will certainly give you a helpful error message.

From a quick look at the command line given I would say that -xc and -fpch-preprocess are no valid vbcc options.
phx is offline  
Old 10 February 2020, 14:05   #3
iliak
Registered User
 
Join Date: Jan 2008
Location: somewhere
Posts: 45
Hi Phx,

The problem is that thoses parameters are automagically added by CLion not by me...

My idea is to adapt a working project to CLion
iliak is offline  
Old 12 February 2020, 08:36   #4
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
I created a project here https://github.com/skeetor/amiga-utils where I integrated gcc and vasm into a cmake compiler. The relevant files can be found here: https://github.com/skeetor/amiga-uti...utilslib/CMake
I had to create a new "compiler" to make it work. The advantage is that the projectfiles are then rather small: Here is a sample how my CMake project file looks: https://github.com/skeetor/amiga-uti...CMakeLists.txt

Don't know if that will work easily with CLion, as I also didn't get it to work with my setup.
sparhawk is offline  
Old 12 February 2020, 09:27   #5
iliak
Registered User
 
Join Date: Jan 2008
Location: somewhere
Posts: 45
Quote:
Originally Posted by sparhawk View Post
I created a project here https://github.com/skeetor/amiga-utils where I integrated gcc and vasm into a cmake compiler. The relevant files can be found here: https://github.com/skeetor/amiga-uti...utilslib/CMake
I had to create a new "compiler" to make it work. The advantage is that the projectfiles are then rather small: Here is a sample how my CMake project file looks: https://github.com/skeetor/amiga-uti...CMakeLists.txt

Don't know if that will work easily with CLion, as I also didn't get it to work with my setup.

I'll have a look, thx
iliak is offline  
Old 12 February 2020, 10:08   #6
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
If you create your own cmake compiler you don't need that enable language part, as C/CPP files are known anyway. You still have to create an appropriate VBCC compiler though, which tells cmake what options it needs to set.
If you get CLion to work, I would be interested in it, as I currently use Notepad++, but CLion is much nicer to use.

There is also some support for cmake with cross compiling https://gitlab.kitware.com/cmake/com...CrossCompiling so maybe this is also some help.
sparhawk is offline  
Old 12 February 2020, 15:01   #7
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
CLion works for me with gcc.

As an example see https://github.com/alexalkis/a68k/bl...CMakeLists.txt
alkis is offline  
Old 12 February 2020, 15:24   #8
iliak
Registered User
 
Join Date: Jan 2008
Location: somewhere
Posts: 45
My current project uses m68k GCC-6.4 too, but I can't compile the following code :
Code:
long toto(register long a __asm("d1")) { return a; }

I can't /don't know how to make gcc puts function parameters in registers...

That's why I want to use vbcc
iliak is offline  
Old 12 February 2020, 15:35   #9
arcanist
Registered User
 
Join Date: Dec 2017
Location: Austin, TX
Age: 41
Posts: 405
Quote:
Originally Posted by iliak View Post
My current project uses m68k GCC-6.4 too, but I can't compile the following code :
Code:
long toto(register long a __asm("d1")) { return a; }

I can't /don't know how to make gcc puts function parameters in registers...

That's why I want to use vbcc
The gcc prototype would be:

Code:
long toto(long a __asm("d1"));
That's how I've mixed C and assembly in my project.

If you don't care about the specific registers and just want to avoid passing on the stack, I think the -mregparm option is meant to do that.
arcanist is offline  
Old 12 February 2020, 15:56   #10
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Quote:
Originally Posted by alkis View Post
CLion works for me with gcc.

As an example see https://github.com/alexalkis/a68k/bl...CMakeLists.txt

Are you running CLion in Linux? I would assume that it might work there. On Windows I would liketo know how to set it up with MKSYS2 and the amigaos toolchain from bebbo.
sparhawk is offline  
Old 12 February 2020, 16:04   #11
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
I have done some work with CMake as well: https://github.com/AmigaPorts/AmigaC...ossToolchains/

I haven't added VBCC, but VASM support, because I needed it in a project.

This toolchain is used in the amigadev/crosstools:m68k-amigaos docker image. (source: https://github.com/AmigaPorts/docker-amiga-gcc/)

This contains all the compiler modules needed to enable VASM:
https://github.com/AmigaPorts/AmigaC...s/m68k-amigaos

Sparhawk: I'll gladly work together with you to make this the ultimate Amiga CMake package, if you'd like.
Marlon_ is offline  
Old 12 February 2020, 16:22   #12
sparhawk
Registered User
 
sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
Quote:
Originally Posted by Marlon_ View Post
Sparhawk: I'll gladly work together with you to make this the ultimate Amiga CMake package, if you'd like.

That would be cool. My toolchain works for me, but I wouldn't be surprised if there is a more elegant approach. My goal was to ideally have only a minimum of setup steps in a cmake project, which means that I want only use find_package() and everything else is automatically properly configured.
sparhawk is offline  
Old 12 February 2020, 17:16   #13
Marlon_
AmigaDev.com
 
Marlon_'s Avatar
 
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
Quote:
Originally Posted by sparhawk View Post
That would be cool. My toolchain works for me, but I wouldn't be surprised if there is a more elegant approach. My goal was to ideally have only a minimum of setup steps in a cmake project, which means that I want only use find_package() and everything else is automatically properly configured.
My goal is to have an as much ready to go prebuilt environment for people to use with whichever Amiga flavor they want. Hence the docker.

My improvements are on all ends in the case of Docker:
* Environment variables set for CC, CXX, AR, LD, RANLIB etc,
* Aliases for m68k-amigaos-gcc to just gcc etc (so it's like how it would be when compiling directly on Amiga with a Makefile)
* using cmake, the m68k-amigaos.cmake toolchain file is preloaded and has all the required variables, so all you need to do is: mkdir build && cd build && cmake .. && make
* CMake modules for VASM is preinstalled in the proper directory so enable_language(ASM-VASM) works without extra tinkering

What could be improved is how the ASM-VASM files are setup, and adding VBCC as a C/C++ compiler variant.

I've sent an invite to be part of AmigaDev/AmigaPorts and granted you access to the AmigaCMakeToolchains repository.
Marlon_ is offline  
Old 13 February 2020, 13:04   #14
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by sparhawk View Post
Are you running CLion in Linux? I would assume that it might work there. On Windows I would liketo know how to set it up with MKSYS2 and the amigaos toolchain from bebbo.
Indeed this is on linux.
alkis is offline  
Old 13 February 2020, 13:09   #15
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
Quote:
Originally Posted by iliak View Post
My current project uses m68k GCC-6.4 too, but I can't compile the following code :
Code:
long toto(register long a __asm("d1")) { return a; }

I can't /don't know how to make gcc puts function parameters in registers...

That's why I want to use vbcc
It works on beboo's gcc-6.5
https://franke.ms/cex/z/N4LiRl
alkis is offline  
Old 19 May 2020, 04:04   #16
ReadOnlyCat
Code Kitten
 
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
Quote:
Originally Posted by Marlon_ View Post
My goal is to have an as much ready to go prebuilt environment for people to use with whichever Amiga flavor they want. Hence the docker.
Looking at the Docker files, this seems to only run on Linux though right?

Quote:
Originally Posted by Marlon_ View Post
What could be improved is how the ASM-VASM files are setup, and adding VBCC as a C/C++ compiler variant.
I am currently converting a Sublime Text project into a CLion one (Sublime is nice but lacks the smarts of CLion) so I think I am going to give the latter (VBCC setup) a try.
At the moment I am building (on macOS) via a simple
build.sh
script but that is obviously not be scalable in the long run.

I am not a big CMake fan (to be polite ) but that will be better than nothing.
ReadOnlyCat is offline  
Old 19 May 2020, 09:01   #17
iliak
Registered User
 
Join Date: Jan 2008
Location: somewhere
Posts: 45
I would be interestd in a CLion project too
iliak is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
GCC/VASM with CMake sparhawk Coders. C/C++ 1 20 December 2019 19:10
CMake and vasm sparhawk Coders. General 9 30 November 2019 21:04
[upcoming project] project name hard'n'heavy Kojote project.Amiga Game Factory 0 22 March 2018 15:28
Natami project freezed, Tina project folded...what next?? Bamiga2002 Amiga scene 52 21 May 2014 09:19
CMake for WinUAE gilgamesh request.UAE Wishlist 1 08 February 2010 00:28

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:00.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11742 seconds with 16 queries