-
Notifications
You must be signed in to change notification settings - Fork 284
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
Toxcore does not build with cmake on OpenBSD. #881
Comments
What operating system are you trying to build toxcore on? |
@endoffile78 OpenBSD |
I just tried on my OpenBSD virtual machine and I get the same thing. I tried both gcc and clang. I'm running OpenBSD 6.3. |
If you leave it as is, does it build on OpenBSD? I.e. does removing those lines cause the undefined references? According to which standard is alloca supposed to be available in stdlib.h? It's inherently a non-standard function, neither in any C nor in any POSIX standard document. On Linux/glibc, if you ask the compiler for C99 compliance, alloca is not available, hence the ifdef mess. Long term, I'd like to get rid of stack allocated buffers or at least allocate the maximum buffer every time (so no VLAs or alloca) so we can calculate the maximum stack depth. |
First, I don't have <alloca.h> header:
Second, leaving it as is does not help to build (it didn't start building toxcore/ccompat.h, but at release 0.2.0 it returned error because toxcore/ccompat.h tried to include <alloca.h>), still a flood of undefined references: https://pastebin.com/raw/8g9iyw2i Third, according to man pages at Linux, FreeBSD, NetBSD and OpenBSD alloca() is terrible. Fourth, it seems that including <stdlib.h> at Linux will work if you don't use -ansi and -std=c* with gcc https://man.openbsd.org/Linux-4.13/alloca#Notes_on_the_GNU_version |
Thanks for reporting this. I'm very keen on making things portable. The introduction of alloca was to allow compilation on MSVC and other compilers not supporting VLAs. The gcc compilation shouldn't need it. The linker errors you're getting are not related to alloca, but are interesting. It seems the libc is not linked to the library, which can make sense. Some build systems do this on systems where undefined references are supported in dynamic libraries. The linker flag "-z defs" is the likely reason for these errors. I'll check with endoffile78 whether removing that flag fixes it. |
@iphydf If some compilers don't support VLAs, what's wrong with using malloc(3) (or calloc(3)) instead of alloca(3)? Anyway, I am going to make 0.2.2 port. |
I've taken a look into toxcore/ccompat.h and this is what worries me:
As far as I know <alloca.h> is a Linux-specific header (and perhaps also MacOS-specific header). That means toxcore works only at Windows, Linux and FreeBSD...
@iphydf Do you know that alloca(3) and malloc(3) are supposed to be at <stdlib.h> at any OS, including Windows and Linux? So this should work not only for FreeBSD:
But quickly patching that doesn't help, I get a spam of undefined references: https://pastebin.com/raw/NbrasTWR
What have you done? You made toxcore completely non portable!
The text was updated successfully, but these errors were encountered: