Builtins.def compile error on Windows

The file include/llvm/Config/alloca.h has a “#define alloca _alloca” which substitutes the “alloca” in Builtins.def, resulting in the Builtin::BIalloca reference in CGBuiltin.cpp being undefined.

Changing “LIBBUILTIN(alloca, “vz", “f”, “stdlib.h”)" to "LIBBUILTIN(_alloca, "vz”, “f”, “stdlib.h”)”,
and the one reference to “Builtin::BIalloca” to “Builtin::BI_alloca” in CGBuiltin.cpp seems an easy fix, but I don’t know if there are other issues with this.

i.e. the name being used in a string table or lookup somewhere. What’s a better fix?

i.e. the name being used in a string table or lookup somewhere. What's a

better fix?

The file include/llvm/Config/alloca.h has a "#define alloca _alloca" which

substitutes the

"alloca" in Builtins.def, resulting in the Builtin::BIalloca reference in

CGBuiltin.cpp being

undefined.

Changing "LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")" to
         "LIBBUILTIN(_alloca, "v*z", "f", "stdlib.h")",

and the one reference to "Builtin::BIalloca" to "Builtin::BI_alloca" in

CGBuiltin.cpp seems

an easy fix, but I don't know if there are other issues with this.

--
John Thompson
John.Thompson.JTSoftware@gmail.com

Thanks for tracking this down John - it explains the build problems I was
having last week,
and why no-one else could reproduce them - I'm assuming Windows builds are
not regularly
tested.

I've been working around this by commenting out the reference to
Builtin::BIalloca as I
had no idea where it came from, and I guess that is no longer to correct
solution either!

Unfortunately I have no ideas for a better resolution myself.

AlisdairM

The file include/llvm/Config/alloca.h has a "#define alloca _alloca" which
substitutes the "alloca" in Builtins.def, resulting in the Builtin::BIalloca
reference in CGBuiltin.cpp being undefined.

Ouch, that's really, really, nasty.

Changing "LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")" to
"LIBBUILTIN(_alloca, "v*z", "f", "stdlib.h")",
and the one reference to "Builtin::BIalloca" to "Builtin::BI_alloca" in
CGBuiltin.cpp seems an easy fix, but I don't know if there are other issues
with this.

That's quite clearly the wrong fix: it's supposed to detect "alloca",
not "_alloca". The "alloca" being referred to here is from the source
code being compiled and has nothing to do with any alloca function
available on the host.

Can you find where include/llvm/Config/alloca.h is getting included
from? I can't seem to figure it out.

The whole thing is rather fragile, and should probably be rewritten to
use Tablegen or something like that, but that's a long-term project.

-Eli

Eli Friedman wrote: