Closed vaind closed 4 years ago
Flags are not necessarily defined. The headers allow for them to be defined. You can do it with -D FLATCC_USE_GENERIC_ALIGNED_ALLOC
on the compiler command line, or you can customize flatcc_rtconfig.h
On the first error, maybe there is a missing header include, or maybe the compiler is between two chairs: aligned_alloc is a C11 feature that wasn't in glibc for the longest time, but as I recall it should not require any special headers. You could try compile with -std=c11 to see if that changes anything. Maybe something needs to be updated here - much of the logic is around dealing with glibc not doing what it should be doing here.
I can't really help more, since it requires the system that you are using. If you can figure out what needs to be patched, if you care enough, I can add it if it won't break other stuff.
As to the last error: 'void*' to 'char*'
that sounds really odd, but with gcc all warnings and errors are odd these days. What compiler version are you using, and have you disabled -pedantic
? Not sure what -fpermissive
means, as it doesn't sound very permissive.
Again, I can't do much from here. It depends on the specific compiler, and gcc has a policy of being very obnoxious because they think everyone only compiles with gcc.
The compiler is GCC 9.2. I'll look into the rest of your comment, thanks
doh, I could just read the CMake output to get the compiler version, but thanks :)
Here is a 13 day old build on the flatcc ci-more branch. This branch isn't built regularly except up to a release, as it covers a lot of compiler versions. In this build a gcc 9.3 compiler passes on Ubuntu 18.04:
whole build: https://travis-ci.org/github/dvidelabs/flatcc/builds/696593748
subsystem job under build: gcc-9 (Ubuntu 9.3.0-11ubuntu0~18.04.1) 9.3.0 https://travis-ci.org/github/dvidelabs/flatcc/jobs/696593751
Yes, I'm aware this works fine on Ubuntu, it's certainly related to MinGW (windows). I'll try some more stuff shortly and let you know if I can get it working after all
Is _WIN32 defined? That could potentially throw the system off if not using MSVC.
I found this in your CMake log:
Configured C_FLAGS: -DFLATCC_REFLECTION=1 -std=c11 -pedantic -Wall -Wextra -Wno-stringop-truncation -Wno-format-overflow -Werror -Wno-unused-function -Wsign-conversion
You definitely need to remove -pedantic
. That is officially not supported as of gcc 8.0 as it forces things to break, and too much maintenance each gcc release forward. As for other settings, see comments in the flatcc CMakeList.txt on gcc.
-Wsign-conversion support was recently added, at least for clang, but I'm not sure about gcc.
-pedantic is set up by default by the tdm-gcc but they're just warnings, no errors so won't help here.
Win32 is defined
I'm trying to track the code path being executed, it's getting here:
however, that doesn't end up generating any code because it's not MSVC
I'll check if I can get it to work by defining FLATCC_USE_GENERIC_ALIGNED_ALLOC
Did you notice:
#if 0
#define PORTABLE_DEBUG_ALIGNED_ALLOC
#endif
If you flag that in, you should get more information.
Not really, it'll just error out on line 99 :/
portable/paligned_alloc.h:99:2: error: #error "DEBUG: C11_ALIGNED_ALLOC configured"
99 | #error "DEBUG: C11_ALIGNED_ALLOC configured"
I'm wondering why this doesn't trigger, given -stcd=c11
#if defined (_ISOC11_SOURCE)
/* glibc aligned_alloc detection. */
#define PORTABLE_C11_ALIGNED_ALLOC 1
#elif defined (__GLIBC__)
...
Or maybe it does trigger, but it doesn't work, because of MINGW?
I posted at the same time as you. It confirms it. So, the key is to figure out how to either not detect C11 support in this case, or to figure out why the code breaks when there is support.
I think the problem is on line 44
#if defined (_ISOC11_SOURCE)
/* glibc aligned_alloc detection. */
#define PORTABLE_C11_ALIGNED_ALLOC 1
#elif defined (__GLIBC__)
The _ISOC11_SOURCE might be defined which overrides the glibc version check and thereby claims there is a built-in aligned_alloc.
Maybe this is correct. But it still causes an error. I suspect it is correct since there is a mention of built-in aligned_alloc in your log.
Can you check if you have a path where stdlib.h is not included where it is needed?
Z:\objectbox-generator\third_party\flatcc\src\src\runtime\builder.c:21:1: note: include '<stdlib.h>' or provide a declaration of 'aligned_alloc'
20 | #include "flatcc/flatcc_emitter.h"
+++ |+#include <stdlib.h>
I'm wondering why this doesn't trigger, given -stcd=c11
#if defined (_ISOC11_SOURCE) /* glibc aligned_alloc detection. */ #define PORTABLE_C11_ALIGNED_ALLOC 1 #elif defined (__GLIBC__) ...
Or maybe it does trigger, but it doesn't work, because of MINGW?
Well even after changing to #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
, which should be the thing you were looking for, semantically (C 11), it still doesn't help of course, since PORTABLE_C11_ALIGNED_ALLOC
isn't used later to define anything
Well, <stdlib.h>
is always included in paligned_alloc.h
, so that doesn't make any sense.
Is PORTABLE_C11_ALIGNED_ALLOC
meant to mean there IS already an existing aligned_alloc? Just trying to understand
Exactly
looks like mingw doesn't have one: https://github.com/ebassi/graphene/issues/83
Then mingw shouldn't define _ISOC11_SOURCE
but there we go.
Can you propose a detection mechanism? This is fragile if MingW defines it later.
I've searched among system headers and aligned_alloc
it isn't defined anywhere.
I've got it working for now using export CFLAGS=-DFLATCC_USE_GENERIC_ALIGNED_ALLOC=1
but am not really sure what would be the best option
I'm gonna push a branch shortly for you to test
Please have a look at https://github.com/dvidelabs/flatcc/tree/mingw
It is not tested on MingW of course, but it is a start.
Yep, that commit helps and RT lib now compiles.
Thats great, I'll merge that to master. I just added a commit with a non-MingW line I accidentally deleted.
Note that you will need aligned_free for MingW (non-standard), but _aligned_malloc does not support free.
Thx, feel free to close this
OK, what about the other warning/error?
And can you please recheck on master to ensure things are ok?
Ah the other issue was aligned_free missing. You can close when master is confirmed. Thanks for raising this issue and debugging.
seems to work fine
thx again
Trying to compile flatcc with MinGW (TDM GCC 64) and I am having two, seemingly small, issues:
1. Compiling RT lib
I'm not entirely sure what's wrong but I was able to make it compile (i.e. the following error wouldn't show), if I flipped the
#ifndef FLATCC_USE_GENERIC_ALIGNED_ALLOC
toifdef
... Couldn't find where that flag is being set though :man_shrugging:2. When included in a simple main.c
After I hacked the ifdef above I got it compiled but got to the next error in asignment. Also seems to be fixed by a correct cast after indexing.