visopsys.org

Visopsys Forums
It is currently Sun Jan 21, 2018 4:04 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to compile applications for Visopsys quickly and easily
PostPosted: Sat Mar 29, 2014 11:49 pm 
Offline

Joined: Sun Sep 01, 2013 7:58 pm
Posts: 29
Right now it appears that the way most people use to compile applications for Visopsys is to place the code in the Visopsys source tree, and let the makefiles in there do the work; while that is fine if you are coding an application that is going to be contributed to Visopys' core system, for many applications that is unsuitable.

My way of compiling applications for Visopsys is to setup a "cross-compiler" (it is not a real cross compiler, just a wrapper, but it somewhat works like one).
I do the following:
    I make a directory tree at, for instance, /usr/local/visopsys. I create the bin, include and lib directories inside /usr/local/visopsys
    I copy the contents of the header directory from the Visospys CD and I place them inside the "include" directory
    I do likewise for the contents of the libraries directory from the CD, placing them inside the "lib" directory
    I make and place a shell script that will act as a wrapper, calling GCC with the right options; I will call such script visgcc and place it in the "bin" directory
    When I want to compile something for Visopsys, I call the "visgcc" wrapper script

An example wrapper script (visgcc):
Code:
gcc -m32  -fno-common -fno-strict-aliasing -fno-builtin -nostdinc -nostdlib -L/usr/local/visopsys/lib -I/usr/local/visopsys/include -Wl,/usr/local/visopsys/lib/crt0.o,--warn-common,-X,--oformat,elf32-i386 -lc -D__VISOPSYS__ $* -lgcc


An example wrapper script, for CLang (visclang):
Code:
clang -m32  -fno-common -fno-strict-aliasing -fno-builtin -nostdinc -nostdlib -L/usr/local/visopsys/lib -I/usr/local/visopsys/include -Wl,/usr/local/visopsys/lib/crt0.o,--warn-common,-X,--oformat,elf32-i386 -lc -D__VISOPSYS__ $* -lgcc


Yes, CLang/LLVM can compile applications for Visospys!

Here is a premade "toolchain", which includes the wrapper scripts + visopsys 0.73 includes + visopsys 0.73 libraries; it installs at /usr/local/visopsys, and it requires that you are on a x86 machine, regardless if it is running a 32-bit or 64-bit *nix-like operating system. I tested it under NetBSD amd64, it works well.

In this way you can compile applications by just changing the compiler name in the Makefiles; granted, many applications won't compile, or if they will compile, they will not work, due to technical problems (C library function broken or faulty).

Anyway..
Enjoy!

_________________
Visopsys@Unhaut - http://unhaut.fav.cc/visopsys


Top
 Profile  
 
 Post subject: Re: How to compile applications for Visopsys quickly and eas
PostPosted: Sun Mar 30, 2014 1:34 am 
Offline
User avatar

Joined: Tue Nov 16, 2010 7:20 pm
Posts: 460
This is great, thanks nextvolume. Yes, creating even a true cross-compiler with GCC isn't too difficult, as you've illustrated with this example. It's just a bit fiddly. The next trick is to compile the compiler with the cross-compiler, and presto: you have a native compiler.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group