[Issue 24389] importC: Building zlib in Phobos with importC fails on FreeBSD 14

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 12 03:09:51 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24389

--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
Created attachment 1905
  --> https://issues.dlang.org/attachment.cgi?id=1905&action=edit
cpp output on .c file containing just #include <stdlib.h>

Okay. My experience with importC at this point is pretty much zero, so my
experience with debugging it is zero, and I could be going about this the wrong
way, but rather than try to fight the Phobos build to try to run specific build
commands on stuff, I tried to reduce this to something simple that I can easily
run build commands on, and given that the problem seems to be with stdlib.h,
that should be straightforward. So, I created a file called a.c that was just

---
#include <stdlib.h>
---

and ran

   dmd a.c

which results in basically the same error as the Phobos build (except only
once):

---
/usr/include/stdlib.h(352): Error: no type for declarator before `asm`
---

I ran

   cpp a.c > b.c

and attached b.c here. However running

   dmd b.c

results in exactly the same error.

---
/usr/include/stdlib.h(352): Error: no type for declarator before `asm`
---

So, I don't know if that's helpful (since I would have thought that it would
then show an error inside of b.c instead), but b.c does end up with

---
void __qsort_r_compat(void *, size_t, size_t, void *,
     int (*)(void *, const void *, const void *));
__asm__(".symver " "__qsort_r_compat" ", " "qsort_r" "@" "FBSD_1.0");
---

inside of it, which presumably is what you were looking for. Sticking just that
in a file called c.c and running

   dmd c.c

results in

---
c.c(3): Error: no type for declarator before `asm
---

Hopefully that's generated from the same version of the macro that's used when
zlib imports it in the Phobos build. I know that the dmd / Phobos build at
least used to need gcc on FreeBSD for some stuff, but I don't know if it's
currently required or used, and running cpp is definitely running clang. Either
way, the error is the same.

So, hopefully that helps. If you need me to run something else, just ask. I
don't have much experience trying to debug preprocessor issues (and what
experience I do have is about a decade old at this point), though I guess that
that's technically more experience than I have with importC.

--


More information about the Digitalmars-d-bugs mailing list