I could fix building nim on FreeBSD-9.3 by making the following changes in the Nim/csources dir. But apparently stdlib_net.c is autogenerated so the ./koch boot -d:release step fails (see the error at the end). My guess is some template needs to be fixed so that |#include <sys/types.h>| gets generated. I couldn't locate how this is generated in the few minutes I spent. Hope this is enough for someone more knowledgeable than me to fix this. Thanks!
--git a/build.sh b/build.sh
index 692008d..04ee1e3 100644
--- a/build.sh
+++ b/build.sh
@@ -61,7 +61,7 @@ case $uos in
myos="freebsd"
CC="clang"
LINKER="clang"
- LINK_FLAGS="$LINK_FLAGS -ldl -lm"
+ LINK_FLAGS="$LINK_FLAGS -lm"
;;
*openbsd* )
myos="openbsd"
diff --git a/c_code/5_2/stdlib_net.c b/c_code/5_2/stdlib_net.c
index 14132e2..78d6d3a 100644
--- a/c_code/5_2/stdlib_net.c
+++ b/c_code/5_2/stdlib_net.c
@@ -4,6 +4,7 @@
#define NIM_INTBITS 64
#include "nimbase.h"
+#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
And this is the error:
-c -w -O3 -I/home/bakul/github/Araq/Nim/lib -o compiler/nimcache/stdlib_net.o compiler/nimcache/stdlib_net.c
compiler/nimcache/stdlib_net.c:358:39: error: use of undeclared identifier
'u_int32_t'
name.sin_addr.s_addr = htonl_542807(INADDR_ANY);
^
/usr/include/netinet/in.h:46:22: note: expanded from macro 'INADDR_ANY'
#define INADDR_ANY (u_int32_t)0x00000000
^
1 error generated.
I've been having a go at getting Nim v0.10.2 running on FreeBSD 10.1, and I received the same error while compiling Nimble. I suspect this might be the same issue, as the C source compiled when I made the change you suggest above.
I had a look at the Nim library source, and I think I found the place where types.h needs to be added:
--- lib/posix/posix.nim.orig 2015-03-14 02:27:11.523449818 +0000
+++ lib/posix/posix.nim 2015-03-14 02:28:06.763453266 +0000
@@ -453,7 +453,7 @@
l_linger*: cint ## Linger time, in seconds.
TInPort* = int16 ## unsigned!
- TInAddrScalar* = int32 ## unsigned!
+ TInAddrScalar* {.importc: "u_int32_t", header: "<sys/types.h>", final, pure.} = int32 ## unsigned!
TInAddrT* {.importc: "in_addr_t", pure, final,
header: "<netinet/in.h>".} = int32 ## unsigned!
This seems to allow Nimble to compile without issue.
I have also been looking at bringing the port up to date. I have sent the changes I made to the port maintainer.
Cool. I'll look at bringing this version into the port.
Thanks.