spicyfish / freenos

Automatically exported from code.google.com/p/freenos
GNU General Public License v3.0
0 stars 0 forks source link

Compilation on at least OpenBSD 4.5 fails #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Compilation of FreeNOS currently fails under at least OpenBSD 4.5, with GCC
3.3.4.
The following error message is thrown:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
CXX lib/liballoc/Allocator.o
In file included from include/kernel/Process.h:24,
from include/FreeNOS/Process.h:35,
from lib/libposix/sys/types.h:21,
from lib/libc/Default.h:23,
from <command line>:6:
include/Vector.h:35: error: template with C linkage
In file included from include/kernel/Process.h:25,
from include/FreeNOS/Process.h:35,
from lib/libposix/sys/types.h:21,
from lib/libc/Default.h:23,
from <command line>:6:
...

Original issue reported on code.google.com by coenbijlsma on 7 Aug 2009 at 11:00

GoogleCodeExporter commented 9 years ago
ORIGINAL COMMENT FROM nieklinnenbank
I've discovered that the problem disappears whenever extern "C++" surrounds the
template classes, as described in this post:
http://marc.info/?l=netbsd-users&m=113515650400459&w=2

Original comment by coenbijlsma on 7 Aug 2009 at 11:00

GoogleCodeExporter commented 9 years ago
ORIGINAL COMMENT FROM nieklinnenbank
At this point I managed to successfully compile AND boot an ISO build on 
OpenBSD 4.5.
To solve the template with C linkage problem, we should replace -isystem with 
-I on
OpenBSD, as -isystem
seems to mark files included by -isystem as C files instead of C++ files, but -I
doesn't. It should be safe
to use -I instead of -isystem, as we pass -nostdinc to g++. This behaviour 
currently
happens on all available
compilers on OpenBSD 4.5 (3.3.5 and 4.2.0 20070307).

Another problem with OpenBSD 4.5 is that, it doesn't allow the constructor 
attribute,
with a priority
argument like this: __attribute__((constructor(65535))). We need this, as for 
example
the ELF binary executable
format class needs to register itself to ExecutableFormat::formats, but AFTER 
the
List() class constructor has run.
Otherwise, the pointer ELF had inserted would just be cleared to zero. To try 
out if
the ISO compiled on OpenBSD 4.5
is bootable, I've temporarily hardcoded ELF::__register_ELFdetect() in 
sbin/img/Main.cpp.

Original comment by coenbijlsma on 7 Aug 2009 at 11:00

GoogleCodeExporter commented 9 years ago
ORIGINAL COMMENT FROM nieklinnenbank
I've modified libexec to explicitely add ELF::detect to the formats list. The
system can now be compiled successfully on OpenBSD 4.5, and the ISO is correctly
bootable.

Original comment by coenbijlsma on 7 Aug 2009 at 11:00