How to compile applications for Visopsys quickly and easily

General discussion about Visopsys. We'll create more specific forums if the number of posts justifies that.
Post Reply
nextvolume
Posts: 30
Joined: Sun Sep 01, 2013 7:58 pm

How to compile applications for Visopsys quickly and easily

Post by nextvolume » Sat Mar 29, 2014 11:49 pm

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: Select all

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: Select all

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

User avatar
andymc
Posts: 560
Joined: Tue Nov 16, 2010 7:20 pm

Re: How to compile applications for Visopsys quickly and eas

Post by andymc » Sun Mar 30, 2014 1:34 am

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.

Post Reply