Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile "stream" module into binary. #546

Open
IngwiePhoenix opened this issue Dec 22, 2018 · 5 comments
Open

Failed to compile "stream" module into binary. #546

IngwiePhoenix opened this issue Dec 22, 2018 · 5 comments

Comments

@IngwiePhoenix
Copy link

I was trying to find out how I could compile an all-static binary, but it doesnt load stream now...

[email protected] ~/W/G/d/out $ gcc ../kernel/*.c -o dao -DBSD -DUNIX -DMACOSX -DPLAT=\"macosx\" -DDAO_WITH_THREAD -DDAO_WITH_CONCURRENT -DDAO_WITH_NUMARRAY -DDAO_USE_READLINE -DTRACING_ON -lreadline ../modules/stream/*.c ../modules/auxlib/*.c -I ../kernel/ -I ../modules/auxlib/ -DDAO_HAS_STREAM -DDEBUG
../modules/stream/dao_stream.c:675:9: warning: 'DAO_HAS_STREAM' macro redefined [-Wmacro-redefined]
#define DAO_HAS_STREAM
        ^
<command line>:10:9: note: previous definition is here
#define DAO_HAS_STREAM 1
        ^
1 warning generated.
[email protected] ~/W/G/d/out $ ./dao ../tools/filetools/archive.dao 
[[ERROR]] in file "/Users/Ingwie/Work/Git/dao/tools/filetools/archive.dao":
  At line 1 : Loading failed;

Any idea on how I could fix this? Thanks!

@IngwiePhoenix
Copy link
Author

IngwiePhoenix commented Dec 22, 2018

Well, I got to this point here now:

[email protected] ~/W/G/d/out $ gcc ../kernel/*.c -o dao -DDAO_WITH_NUMARRAY -DDAO_WITH_THREAD -DDAO_WITH_CONCURRENT -DDAO_WITH_RESTART -DTARGET_PLAT=\"macosx\" -DBSD=2 -DMACOSX=3 -DUNIX=1 -DDAO_USE_READLINE -DTRACING_ON -lreadline ../modules/stream/*.c ../modules/auxlib/*.c -I ../kernel/ -I ../modules/auxlib/ -undefined dynamic_lookup -fPIC
[email protected] ~/W/G/d/out $ ./dao ../tools/filetools/archive.dao 
dyld: Symbol not found: __DaoFileStream_Close
  Referenced from: /Users/Ingwie/Work/Git/dao/out/./dao
  Expected in: flat namespace
 in /Users/Ingwie/Work/Git/dao/out/./dao
fish: './dao ../tools/filetools/archiv…' terminated by signal SIGABRT (Abort)

From what I can tell, the usage of DAO_API(...) is causing troubble. This is a static compile, so the functions and signatures should pretty simply be defined "as normal" instead of being exported or anything. Would be nice to have that updated! :)

Edit

nm reports this:

[email protected] ~/W/G/d/out $ nm dao | grep DaoFileStream_Close
00000001000ee390 T _DaoFileStream_Close
                 U __DaoFileStream_Close

Looks like the one being needed is "undefined". I am ... rather surprised.

@IngwiePhoenix
Copy link
Author

Oh... Using -rdynamic helped some - didn't fix the issue, unfortunately...

gcc \
  -I ../kernel/ \
  -I ../modules/ \
  -I ../modules/stream/ \
  -I ../modules/auxlib/ \
  -I ../modules/debugger/ \
  -I ../modules/profiler/ \
  ../kernel/*.c \
  ../modules/stream/*.c \
  ../modules/debugger/*.c \
  ../modules/auxlib/*.c \
  ../modules/profiler/*.c \
  -DBSD \
  -DUNIX \
  -DMACOSX \
  -DPLAT=\"macosx\" \
  -DDAO_WITH_THREAD \
  -DDAO_WITH_CONCURRENT \
  -DDAO_WITH_NUMARRAY \
  -DDAO_USE_READLINE \
  -DTRACING_ON \
  -lreadline \
  -DDAO_HAS_STREAM \
  -DDEBUG \
  -o dao \
  -rdynamic

I'm... so confused on how to get this to work. :/

@dumblob
Copy link

dumblob commented Jan 14, 2019

@IngwiePhoenix sorry for not getting back to you earlier (I'm currently moving to another country and changing my job...). I'll get back to you later.

On the first sight I can tell, that the use of daomake is the only supported way of compiling Dao. Though it should be possible to instruct daomake to compile an all-static binary IIRC.

@IngwiePhoenix
Copy link
Author

Ahh, well that's understandable. Good luck on that! =)

Being able to disassemble the build steps so I can port it to a different build system - which is more convenient to myself - would be very nice. That is why I have been trying to compile Dao straight off the commandline with no build tool in order to reproduce how to compile Dao - without Daomake.

Once you have the time, it'd be nice to hear from you how I could achieve this. Thank you in advance :)

@dumblob
Copy link

dumblob commented Apr 12, 2019

So, I finally found some time and thought a little bit about your effort.

First thing you shall probably know is, that Daomake is basically a standalone pure Dao interpreter but providing few built-in additional classes, objects, routines and constants useful for automated generation of system-specific, more or less POSIX-compliant Makefiles for the make on your system.

Daomake exists because it's super easy and extremely advantageous to leverage basically the biggest in the world mechanism for anything system-specific - which is the C compiler toolchain. This is then compiled on your platform in a form of Daomake which in turn is a super thin layer providing unified interface (used in all makefile.daos) and guaranteeing compatibility with your system at least on the same level as C compiler toolchain would guarantee. Therefore each makefile.dao is just a Dao script generating a Makefile for make.

In this light you could proceed like this.

  1. use Daomake to prepare a dynamically linked build as usual (see e.g. Dao PKGBUILD)
  2. Daomake generates a tree of Makefiles for your system with proper dependencies among them, settings and flags - use these Makefiles as templates for writing Premake(ex.)/cmake/... files
  3. either make a pull request in the staging repo or write a summary here so that it can be put e.g. in the official Dao documentation or at least GitHub wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants