Is core compilable on FreeBSD?

188 views
Skip to first unread message

Kakadu

unread,
Oct 6, 2011, 6:32:03 AM10/6/11
to ocaml-core
My friend has some problems with compilation.

(***************** Configure phase ******************)

I: Running command '/usr/local/bin/ocamlc.opt -config > '/tmp/
oasis-8754b9.txt''

Configuration:

ocamldoc: ...................................... /usr/local/bin/
ocamldoc
pkg_ounit: ..................................... /usr/local/lib/ocaml/
site-lib/oUnit
pkg_threads: ................................... /usr/local/lib/ocaml
pkg_unix: ...................................... /usr/local/lib/ocaml
pkg_res: ....................................... /usr/local/lib/ocaml/
site-lib/res
pkg_bigarray: .................................. /usr/local/lib/ocaml
pkg_bin_prot_syntax: ........................... /usr/local/lib/ocaml/
site-lib/bin_prot
pkg_bin_prot: .................................. /usr/local/lib/ocaml/
site-lib/bin_prot
pkg_fieldslib: ................................. /usr/local/lib/ocaml/
site-lib/fieldslib
pkg_fieldslib_syntax: .......................... /usr/local/lib/ocaml/
site-lib/fieldslib
pkg_sexplib: ................................... /usr/local/lib/ocaml/
site-lib/sexplib
pkg_sexplib_syntax: ............................ /usr/local/lib/ocaml/
site-lib/sexplib
Enable linux specific extensions: .............. false
Build and run tests: ........................... true
OCamlbuild additional flags: ...................
Compile with ocaml profile flag on.: ........... false
Compile with ocaml debug flag on.: ............. true
Remove a directory.: ........................... rm -rf
Remove a file.: ................................ rm -f
suffix_program: ................................
is_native: ..................................... true
findlib_version: ............................... 1.2.7
PS documentation: .............................. $docdir
PDF documentation: ............................. $docdir
DVI documentation: ............................. $docdir
HTML documentation: ............................ $docdir
Documentation root: ............................ $datarootdir/doc/
$pkg_name
Man documentation: ............................. $datarootdir/man
Locale-dependent data: ......................... $datarootdir/locale
Info documentation: ............................ $datarootdir/info
Read-only architecture-independent data: ....... $datarootdir
Read-only arch-independent data root: .......... $prefix/share
Object code libraries: ......................... $exec_prefix/lib
Modifiable single-machine data: ................ $prefix/var
Modifiable architecture-independent data: ...... $prefix/com
Read-only single-machine data: ................. $prefix/etc
Program executables: ........................... $exec_prefix/libexec
System admin executables: ...................... $exec_prefix/sbin
User executables: .............................. $exec_prefix/bin
Install architecture-dependent files in dir: ... $prefix
Install architecture-independent files dir: .... /usr/local
systhread_supported: ........................... true
default_executable_name: ....................... a.out
ext_dll: ....................................... .so
ext_lib: ....................................... .a
ext_asm: ....................................... .s
ext_obj: ....................................... .o
model: ......................................... default
native_c_compiler: ............................. gcc -Wall -
D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE
bytecomp_c_compiler: ........................... gcc -fno-defer-pop -
Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -fPIC
standard_runtime: .............................. /usr/local/bin/
ocamlrun
standard_library: .............................. /usr/local/lib/ocaml
standard_library_default: ...................... /usr/local/lib/ocaml
ocaml_version: ................................. 3.12.1
ccomp_type: .................................... cc
architecture: .................................. amd64
system: ........................................ freebsd
os_type: ....................................... Unix
Package version: ............................... 107.01
Package name: .................................. core
ocamlbuild: .................................... /usr/local/bin/
ocamlbuild
ocamlopt: ...................................... /usr/local/bin/
ocamlopt.opt
ocamlc: ........................................ /usr/local/bin/
ocamlc.opt
ocamlfind: ..................................... /usr/local/bin/
ocamlfind

I: Running command 'lib/discover.sh lib/config.mlh lib/config.h'
discover.sh:40:4: warning: #warning "cpp test --defined(LINUX_EXT)--
was false"
discover.sh:41:4: warning: #warning "Feature LINUX_EXT will not be
availlable"
discover.sh:60:4: warning: #warning "cpp test --
defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0-- was
false"
discover.sh:61:4: warning: #warning "Feature FDATASYNC will not be
availlable"




(*************** Build phase *)

ocaml setup.ml -build
I: Running command '/usr/local/bin/ocamlbuild lib/libcore.a lib/
dllcore.so lib/core.cma lib/core.cmxa lib/core.a lib_test/
test_runner.byte -tag debug'
ocamlfind ocamlc -ccopt -D_LARGEFILE64_SOURCE -c lib/unix_stubs.c
+ ocamlfind ocamlc -ccopt -D_LARGEFILE64_SOURCE -c lib/unix_stubs.c
In file included from lib/unix_stubs.c:43:
/usr/include/net/if.h:305: error: field 'ifru_addr' has incomplete
type
/usr/include/net/if.h:306: error: field 'ifru_dstaddr' has incomplete
type
/usr/include/net/if.h:307: error: field 'ifru_broadaddr' has
incomplete type
/usr/include/net/if.h:343: error: field 'ifra_addr' has incomplete
type
/usr/include/net/if.h:344: error: field 'ifra_broadaddr' has
incomplete type
/usr/include/net/if.h:345: error: field 'ifra_mask' has incomplete
type
/usr/include/net/if.h:433: error: field 'addr' has incomplete type
/usr/include/net/if.h:434: error: field 'dstaddr' has incomplete type
lib/unix_stubs.c:360: warning: 'struct stat64' declared inside
parameter list
lib/unix_stubs.c:360: warning: its scope is only this definition or
declaration, which is probably not what you want
lib/unix_stubs.c: In function 'core_stat_aux_64':
lib/unix_stubs.c:365: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:366: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:367: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:368: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:370: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:371: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:372: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:374: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:375: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:376: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:377: error: dereferencing pointer to incomplete type
lib/unix_stubs.c:378: error: dereferencing pointer to incomplete type
lib/unix_stubs.c: In function 'core_unix_stat_64':
lib/unix_stubs.c:398: error: storage size of 'buf' isn't known
lib/unix_stubs.c:401: warning: implicit declaration of function
'stat64'
lib/unix_stubs.c:398: warning: unused variable 'buf'
lib/unix_stubs.c: In function 'core_unix_lstat_64':
lib/unix_stubs.c:412: error: storage size of 'buf' isn't known
lib/unix_stubs.c:415: warning: implicit declaration of function
'lstat64'
lib/unix_stubs.c:412: warning: unused variable 'buf'
lib/unix_stubs.c: In function 'core_unix_fstat_64':
lib/unix_stubs.c:425: error: storage size of 'buf' isn't known
lib/unix_stubs.c:427: warning: implicit declaration of function
'fstat64'
lib/unix_stubs.c:425: warning: unused variable 'buf'
lib/unix_stubs.c:630:2: warning: #warning "_POSIX_SYNCHRONIZED_IO
undefined or <= 0; unix_fdatasync undefined"
lib/unix_stubs.c: In function 'unix_clock_process_cputime_id_stub':
lib/unix_stubs.c:881: error: 'CLOCK_PROCESS_CPUTIME_ID' undeclared
(first use in this function)
lib/unix_stubs.c:881: error: (Each undeclared identifier is reported
only once
lib/unix_stubs.c:881: error: for each function it appears in.)
lib/unix_stubs.c:1160:2: error: invalid preprocessing directive #warn
Command exited with code 2.
E: Command '/usr/local/bin/ocamlbuild lib/libcore.a lib/dllcore.so lib/
core.cma lib/core.cmxa lib/core.a lib_test/test_runner.byte -tag
debug' terminated with error code 10
gmake: *** [build] Error 1


----------
Best wishes,
Kakadu

Yaron Minsky

unread,
Oct 6, 2011, 7:06:05 PM10/6/11
to ocaml...@googlegroups.com

Sorry for the slow response!  It's been a bit of a crazy day.

We've tested core only on Linux and macos,  so it's not too surprising that there are some portability issues in the c bindings.  Do you know what version of freebsd this was on?

Kakadu

unread,
Oct 7, 2011, 11:19:16 AM10/7/11
to ocaml-core
8.2-stable

P.S. on windows there are some problems too, but it will be another
discussion :-)

Dmitry Astapov

unread,
Oct 10, 2011, 3:07:49 AM10/10/11
to ocaml-core
Looks like FreeBSD's family of *stat* calls is 64-bit by default, so
'#define stat64 stat' (and likewise for fstat, lstat) in unix_stub.c
might just do the trick.

There is obviously some extra include needed to make 'ifru_addr' error
go away, but I have no idea which one. However, a 'grep -r' for
ifru_addr in /usr/include might give some hints.

Line 1160 needs a '#warn -> #warning' change.

I have no ideas for CLOCK_PROCESS_CPUTIME_ID though :(

Kakadu

unread,
Oct 10, 2011, 8:26:16 AM10/10/11
to ocaml-core
New info from my friend:
We should add #include <sys/socket.h> to fix problem with ifru_addr

Dmitry Astapov

unread,
Oct 11, 2011, 5:10:13 AM10/11/11
to ocaml-core
So, after all those changes, what is the final list of errors that
still need fixing?

Brandon Mitchell

unread,
Oct 26, 2011, 1:37:03 PM10/26/11
to ocaml-core
I did the following to compile core on FreeBSD 8.2-RELEASE:

* for the ifru_addr issue:
#if defined(__FreeBSD__)
# include <sys/socket.h>
#endif

* for stat support:
#if defined(__FreeBSD__)
# define stat64 stat
# define lstat64 lstat
# define fstat64 fstat64
typedef struct stat stat_wrapper_t
#else
typedef struct stat64 stat_wrapper_t
#endif

Change all "struct stat" in unix_stubs.c to "stat_wrapper_t"

* for clock cputime support:
#if defined(CLOCK_PROCESS_CPUTIME_ID) && defined(__linux__)
# define CLOCK CLOCK_PROCESS_CPUTIME_ID
#elif defined(CLOCK_PROF) && defined(__FreeBSD__)
# define CLOCK CLOCK_PROF
#else
# define CLOCK CLOCK_REALTIME
#endif

Change the CLOCK_PROCESS_CPUTIME_ID to CLOCK

* Change #warn to #warning

Brandon Mitchell

unread,
Oct 26, 2011, 1:49:16 PM10/26/11
to ocaml-core
On Wed, Oct 26, 2011 at 10:37 AM, Brandon Mitchell <bra...@twitter.com> wrote:
> #   define fstat64 fstat64

Typo. This should be #define fstat64 fstat. Blush.

Yaron Minsky

unread,
Oct 26, 2011, 4:46:03 PM10/26/11
to ocaml...@googlegroups.com
Sounds like a few people are working on patches for FreeBSD. We have
one here, Anil Madhavapeddy is working on one, and now yours.

We'll post our patch here. Hopefully we can get this sorted in a new
release once we have the github repos up.

y

--
Yaron Minsky

Anil Madhavapeddy

unread,
Oct 26, 2011, 7:12:15 PM10/26/11
to ocaml...@googlegroups.com
I've been porting Core and its dependent libraries to OpenBSD, not FreeBSD (many, but not all, of the fixes will be relevant though).
https://github.com/avsm/openbsd-ports/compare/124e9160d9...2bbe16f108

Only main patches so far are for bin-prot:
https://github.com/avsm/openbsd-ports/compare/124e9160d9...2bbe16f108#diff-25

For ocaml-core the patches are here:
https://github.com/avsm/openbsd-ports/tree/master/devel/ocaml-core/patches

The discover.sh needs to not hardcode bash.
unix_stubs.c is pretty big. In particular, the tests currently fail at start of day due to one of the Linux-specific sysconf calls failing.

I'll take a look in more detail later this week...

Anil

Yaron Minsky

unread,
Oct 26, 2011, 7:34:52 PM10/26/11
to ocaml...@googlegroups.com
Sorry.  You BSD's all look alike to me.

<ducks>

As for bin-prot, there are a number of portability fixes that came from Debian that Markus Mottl has included in his version of bin-prot.  We'll need to merge all this stuff together (on github) soon.

y

Brandon Mitchell

unread,
Oct 26, 2011, 8:09:28 PM10/26/11
to ocaml...@googlegroups.com
On Wed, Oct 26, 2011 at 4:12 PM, Anil Madhavapeddy <an...@recoil.org> wrote:
> I've been porting Core and its dependent libraries to OpenBSD, not FreeBSD (many, but not all, of the fixes will be relevant though).
> https://github.com/avsm/openbsd-ports/compare/124e9160d9...2bbe16f108

I can contribute FreeBSD support; I'm not sure who maintains the ports
though. I build and test on both FreeBSD and Ubuntu, but I suspect the
latter to be plenty will supported by other users. Obviously, upstream
contributions will become much easier when Core, et al. are available
on GitHub... *cough* ;-)

Reply all
Reply to author
Forward
0 new messages