daokoder / dao

Dao Programming Language
http://daoscript.org
Other
198 stars 19 forks source link

Consider using macros instead of -D to support "quick compiling" #544

Open IngwiePhoenix opened 5 years ago

IngwiePhoenix commented 5 years ago

Hello!

Obviously, in it's current state, this fails quite badly:

Ingwie@Ingwies-Macbook-Pro.local ~/W/G/d/out $ gcc ../kernel/*.c -o dao
../kernel/daoPlatform.c:101:2: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
        gettimeofday( & tv, NULL);
        ^
1 warning generated.
../kernel/daoVmspace.c:2848:8: warning: implicit declaration of function 'getcwd' is invalid in C99 [-Wimplicit-function-declaration]
        cwd = getcwd( masterVmSpace->startPath->chars, 511 );
              ^
../kernel/daoVmspace.c:2848:6: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
        cwd = getcwd( masterVmSpace->startPath->chars, 511 );
            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
Ingwie@Ingwies-Macbook-Pro.local ~/W/G/d/out $ ./dao
fish: './dao' terminated by signal SIGSEGV (Address boundary error)

When using the (dao)makefiles, I see that only a few definitions are actually added, such as -DMACOSX or -DBSD and -DUNIX. This can, in fact, easily be deduced off a few #ifdef checks:

#ifdef __APPLE__
#define MACOSX
#define BSD
#define UNIX
#endif

There is a super comprehensive "feature detection" header here: https://github.com/msadeqhe/platform-id/blob/master/include/platform-id.h

You may be able to pick this up and modify it to automatically define DAO_-macros. This would make blind-compiles like my showcase above possible, simplify the bootstrap process a little and also allow for people with neither make nor any other means of building, to compile this language right away.

Kind regards, Ingwie.

dumblob commented 5 years ago

Well, currently this is what daomake does. The reason is very simple - even though Dao is quite a simple language and the interpreter itself is a short piece of software, maintaining support for "blind-compilation" is a tough exercise. Daomake allows to centralize this issue and make it fully manageable by saying "we support this one clear method and nothing else". Dao is currently very easy to embed and I can't imagine making it easier by supporting "blind compilation".

I myself would love to have "blind compilation", but without the risk, that it won't work in millions of configurations and this bug tracker will have tens of issues just about compilation due to this simple decision. So I believe daomake as the only one supported way how to build Dao is currently not that wrong. Also as I wrote in the [other thread](), feel free to contribute Premake/cmake/... support and I'll be happy to accept it as "dao-contrib" (without taking over the responsibility that it'll be up to date with latest Dao).