HaxeFoundation / hxcpp

Runtime files for c++ backend for haxe
Other
294 stars 187 forks source link

FreeBSD support for hxcpp #277

Closed rudrabhoj closed 9 years ago

rudrabhoj commented 9 years ago

Hello, I am trying to compile hxcpp for FreeBSD, but when I do I get the following error:

[agnis@bhagavati ~/Dev/hxcpp/project]$ neko build.n
Unknown host system: BSD

Neko and Haxe are working fine, I have done many tests with them, all are good. Also using Phaser extern for Haxe, which is working fine too.

rudrabhoj commented 9 years ago

Where is the source of build.n?

andyli commented 9 years ago

Let's make good use of the search function in Github ;) https://github.com/HaxeFoundation/hxcpp/search?utf8=%E2%9C%93&q=%22Unknown+host+system%22&type=Code

rudrabhoj commented 9 years ago

While I am no regular user of github, that should have been obvious to me. sorry :P :P

rudrabhoj commented 9 years ago

So now I guess should search 'linux' in the repository and add FreeBSD option where ever necessary...

rudrabhoj commented 9 years ago

Where HX_WINDOWS, HX_LINUX, etc. are initially defined? I did search this time :P

rudrabhoj commented 9 years ago

Okay I edited all files wherever I find mention of linux and a need to add freebsd support to. But why do we need hxcpp to build hxcpp?

[agnis@bhagavati ~/Dev/hxcpp/project]$ neko build.n freebsd

Build freebsd, link=lib arch=m64
haxelib run hxcpp Build.xml -Dfreebsd -DHXCPP_M64 -Dstatic_link
Library hxcpp is not installed
#### Error building m64

FreeBSD currently don't have working hxcpp. If I had a working hxcpp then why would I compile from source:

[agnis@bhagavati ~/Dev/hxcpp/project]$ neko build.n freebsd

Build freebsd, link=lib arch=m64
haxelib run hxcpp Build.xml -Dfreebsd -DHXCPP_M64 -Dstatic_link
/usr/local/lib/neko/std.ndll: Undefined symbol "WIFEXITED"
#### Error building m64

This is what happens when I try compiling after install hxcpp through haxelib. How to build hxcpp without having hxcpp installed?

andyli commented 9 years ago

neko build.n uses haxelib run hxcpp ..., which calls the run.n in hxcpp. That's why it complains if hxcpp is not installed. To make it works, run haxelib dev hxcpp path/to/hxcpp, which will use the given directory as the hxcpp haxelib, as if it is installed.

andyli commented 9 years ago

HX_* are defined in the toolchain xml files, e.g. HX_WINDOWS is defined in https://github.com/HaxeFoundation/hxcpp/blob/master/toolchain/msvc-toolchain.xml#L52

rudrabhoj commented 9 years ago

Hello, I set the checkout folder as hxcpp.

[agnis@bhagavati ~/Dev/hxcpp/project]$ neko build.n freebsd

Build freebsd, link=lib arch=m64
haxelib run hxcpp Build.xml -Dfreebsd -DHXCPP_M64 -Dstatic_link
This version of hxcpp (/usr/home/agnis/Dev/hxcpp/) appears to be a source/developement version.
Before this can be used, you need to:
 1. Rebuild the main command-line tool, this can be done with:
     cd tools/hxcpp
     haxe compile.hxml
 2. Build the binaries appropriate to your system(s), this can be done with:
     cd project
     neko build.n

I did haxe compile.hxml in tools/hxcpp, it went on smooth. Then I retired neko build.n and I get this error:

[agnis@bhagavati ~/Dev/hxcpp/project]$ neko build.n freebsd

Build freebsd, link=lib arch=m64
haxelib run hxcpp Build.xml -Dfreebsd -DHXCPP_M64 -Dstatic_link
/usr/local/lib/neko/std.ndll: Undefined symbol "WIFEXITED"
#### Error building m64

"WIFEXITED definitions: POSIX documents this in stdlib.h as optional, and is defined there on linux, but on FreeBSD it is not, so we need to include sys/wait.h where POSIX mandates it to be." -[1]

So given that issue is in std.ndll, I can assume this would be solved adding sys/wait.h in neko compilation?

[1] Source: https://github.com/geaaru/geaaru_overlay/blob/master/net-libs/webkit-gtk/files/webkit-gtk-1.10.2-wifexited.patch

andyli commented 9 years ago

You may probably want to discuss that in https://github.com/HaxeFoundation/neko/issues/84

rudrabhoj commented 9 years ago

Yes, that was the case. this wait.h issue as there in hxcpp too at some places, corrected them too. But in project/Build.xml, I am unable to translate this into FreeBSD version

<target id="linuxcompat" output="${LIBPREFIX}linuxcompat${LIBEXTRA}" tool="linker" toolid="${STD_MODULE_LINK}">
  <files id="linuxcompat"/>
  <builddir name="libs/linuxcompat"/>
  <outdir name="${this_dir}/../${DESTDIR}/${BINDIR}"/>
</target>

I just copied it all mindlessly and wrote freebsdcompat, didn't went smooth, here's what i wrote:

<target id="freebsdcompat" output="${LIBPREFIX}freebsdcompat${LIBEXTRA}" tool="linker" toolid="${STD_MODULE_LINK}">
  <files id="freebsdcompat"/>
  <builddir name="libs/freebsdcompat"/>
  <outdir name="${this_dir}/../${DESTDIR}/${BINDIR}"/>
</target>

During compilation it gives following error after compiling std

.........
.........
clang++ -c -fvisibility=hidden -O2 -fpic -fPIC -DHX_FREEBSD -DSTATIC_LINK -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=0 -m64 -DHXCPP_M64 -I/usr/home/agnis/Dev/hxcpp/include -x c++ -frtti -Wno-invalid-offsetof /usr/home/agnis/Dev/hxcpp/project/libs/sqlite/sqlite.cpp -o/usr/home/agnis/Dev/hxcpp/project/libs/std/obj/freebsd64-stat/9133519a_sqlite.o
ar -cr /usr/home/agnis/Dev/hxcpp/lib/FreeBSD64/libsqlite.a @/usr/home/agnis/Dev/hxcpp/project/libs/std/obj/freebsd64-stat/all_objs
ar: warning: can't open file: @/usr/home/agnis/Dev/hxcpp/project/libs/std/obj/freebsd64-stat/all_objs: No such file or directory
ranlib /usr/home/agnis/Dev/hxcpp/lib/FreeBSD64/libsqlite.a
Error: Could not find filegroup freebsdcompat
#### Error building m64
rudrabhoj commented 9 years ago

What is a filegroup??

rudrabhoj commented 9 years ago

Okay I'll use Linux instead :P :/