-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
wasm: no longer compile my project #4324
Comments
|
This is a failure to compile the |
|
you were right, on a blank file with ldc directly it works, but with dub it doesn't Here is the output on a blank source file (just _start) with verbose mode: I downloaded: ldc2-1.31.0-windows-multilib Here is the ldc2.conf |
|
You'd need to get hold of the temp .d file being compiled (with |
|
i haven't modified anything, that's all untouched, i downloaded the compiler from release section and unzipped it there is no dub_platform_probe file, when i compile the project it gets created but it gets instantly removed so i can't open it |
|
i managed to get it by editing dub code module dub_platform_probe;
template toString(int v) { enum toString = v.stringof; }
string stringArray(string[] ary) {
string res;
foreach (i, e; ary) {
if (i)
res ~= ", ";
res ~= '"' ~ e ~ '"';
}
return res;
}
pragma(msg, `__dub_probe_begin__`
~ '\n' ~ `{`
~ '\n' ~ ` "compiler": "`~ determineCompiler() ~ `",`
~ '\n' ~ ` "frontendVersion": ` ~ toString!__VERSION__ ~ `,`
~ '\n' ~ ` "compilerVendor": "` ~ __VENDOR__ ~ `",`
~ '\n' ~ ` "platform": [`
~ '\n' ~ ` ` ~ determinePlatform().stringArray
~ '\n' ~ ` ],`
~ '\n' ~ ` "architecture": [`
~ '\n' ~ ` ` ~ determineArchitecture().stringArray
~ '\n' ~ ` ],`
~ '\n' ~ `}`
~ '\n' ~ `__dub_probe_end__`);
string[] determinePlatform() {
string[] ret;
version(Windows) ret ~= "windows";
version(linux) ret ~= "linux";
version(Posix) ret ~= "posix";
version(OSX) ret ~= ["osx", "darwin"];
version(iOS) ret ~= ["ios", "darwin"];
version(TVOS) ret ~= ["tvos", "darwin"];
version(WatchOS) ret ~= ["watchos", "darwin"];
version(FreeBSD) ret ~= "freebsd";
version(OpenBSD) ret ~= "openbsd";
version(NetBSD) ret ~= "netbsd";
version(DragonFlyBSD) ret ~= "dragonflybsd";
version(BSD) ret ~= "bsd";
version(Solaris) ret ~= "solaris";
version(AIX) ret ~= "aix";
version(Haiku) ret ~= "haiku";
version(SkyOS) ret ~= "skyos";
version(SysV3) ret ~= "sysv3";
version(SysV4) ret ~= "sysv4";
version(Hurd) ret ~= "hurd";
version(Android) ret ~= "android";
version(Cygwin) ret ~= "cygwin";
version(MinGW) ret ~= "mingw";
version(PlayStation4) ret ~= "playstation4";
version(WebAssembly) ret ~= "wasm";
return ret;
}
string[] determineArchitecture() {
string[] ret;
version(X86) ret ~= "x86";
// Hack: see #1535
// Makes "x86_omf" available as a platform specifier in the package recipe
version(X86) version(CRuntime_DigitalMars) ret ~= "x86_omf";
// Hack: see #1059
// When compiling with --arch=x86_mscoff build_platform.architecture is equal to ["x86"] and canFind below is false.
// This hack prevents unnecessary warning 'Failed to apply the selected architecture x86_mscoff. Got ["x86"]'.
// And also makes "x86_mscoff" available as a platform specifier in the package recipe
version(X86) version(CRuntime_Microsoft) ret ~= "x86_mscoff";
version(X86_64) ret ~= "x86_64";
version(ARM) ret ~= "arm";
version(AArch64) ret ~= "aarch64";
version(ARM_Thumb) ret ~= "arm_thumb";
version(ARM_SoftFloat) ret ~= "arm_softfloat";
version(ARM_HardFloat) ret ~= "arm_hardfloat";
version(PPC) ret ~= "ppc";
version(PPC_SoftFP) ret ~= "ppc_softfp";
version(PPC_HardFP) ret ~= "ppc_hardfp";
version(PPC64) ret ~= "ppc64";
version(IA64) ret ~= "ia64";
version(MIPS) ret ~= "mips";
version(MIPS32) ret ~= "mips32";
version(MIPS64) ret ~= "mips64";
version(MIPS_O32) ret ~= "mips_o32";
version(MIPS_N32) ret ~= "mips_n32";
version(MIPS_O64) ret ~= "mips_o64";
version(MIPS_N64) ret ~= "mips_n64";
version(MIPS_EABI) ret ~= "mips_eabi";
version(MIPS_NoFloat) ret ~= "mips_nofloat";
version(MIPS_SoftFloat) ret ~= "mips_softfloat";
version(MIPS_HardFloat) ret ~= "mips_hardfloat";
version(SPARC) ret ~= "sparc";
version(SPARC_V8Plus) ret ~= "sparc_v8plus";
version(SPARC_SoftFP) ret ~= "sparc_softfp";
version(SPARC_HardFP) ret ~= "sparc_hardfp";
version(SPARC64) ret ~= "sparc64";
version(S390) ret ~= "s390";
version(S390X) ret ~= "s390x";
version(HPPA) ret ~= "hppa";
version(HPPA64) ret ~= "hppa64";
version(SH) ret ~= "sh";
version(SH64) ret ~= "sh64";
version(Alpha) ret ~= "alpha";
version(Alpha_SoftFP) ret ~= "alpha_softfp";
version(Alpha_HardFP) ret ~= "alpha_hardfp";
return ret;
}
string determineCompiler() {
version(DigitalMars) return "dmd";
else version(GNU) return "gdc";
else version(LDC) return "ldc";
else version(SDC) return "sdc";
else return null;
}still same cmd: EDIT: and i get: |
|
Yeah, you'll only be able to use dub if that file can be compiled for your target (with |
I've used v1.30 AST: module dub_platform_probe;
import object;
enum toString(int v) = v.stringof;
string stringArray(string[] ary)
{
string res = null;
{
scope string[] __r3 = ary[];
ulong __key2 = 0LU;
for (; __key2 < __r3.length; __key2 += 1LU)
{
string e = __r3[__key2];
ulong i = __key2;
if (i)
res ~= ", ";
res ~= '"' ~ e ~ '"';
}
}
return res;
}
pragma (msg, "__dub_probe_begin__\n{\n \"compiler\": \"" ~ determineCompiler() ~ "\",\n \"frontendVersion\": 2100,\n \"compilerVendor\": \"LDC\",\n \"platform\": [\n " ~ stringArray(determinePlatform()) ~ "\n ],\n \"architecture\": [\n " ~ stringArray(determineArchitecture()) ~ "\n ],\n}\n__dub_probe_end__");
string[] determinePlatform()
{
string[] ret = null;
ret ~= "linux";
ret ~= "posix";
return ret;
}
string[] determineArchitecture()
{
string[] ret = null;
ret ~= "x86_64";
return ret;
}
string determineCompiler()
{
return "ldc";
}
toString!2100
{
enum string toString = "2100";
}v1.31 AST: module dub_platform_probe;
import object;
enum toString(int v) = v.stringof;
string stringArray(string[] ary)
{
string res = null;
{
scope string[] __r3 = ary[];
ulong __key2 = 0LU;
for (; __key2 < __r3.length; __key2 += 1LU)
{
string e = __r3[__key2];
ulong i = __key2;
if (i)
_d_arrayappendT(res, ", ");
_d_arrayappendT(res, '"' ~ e ~ '"');
}
}
return res;
}
pragma (msg, "__dub_probe_begin__\n{\n \"compiler\": \"" ~ determineCompiler() ~ "\",\n \"frontendVersion\": 2101,\n \"compilerVendor\": \"LDC\",\n \"platform\": [\n " ~ stringArray(determinePlatform()) ~ "\n ],\n \"architecture\": [\n " ~ stringArray(determineArchitecture()) ~ "\n ],\n}\n__dub_probe_end__");
string[] determinePlatform()
{
string[] ret = null;
(string __appendtmp7 = "linux";) , (_d_arrayappendcTX(ret, 1LU) , ret[ret.length - 1LU] = __appendtmp7 , ret);
(string __appendtmp8 = "posix";) , (_d_arrayappendcTX(ret, 1LU) , ret[ret.length - 1LU] = __appendtmp8 , ret);
return ret;
}
string[] determineArchitecture()
{
string[] ret = null;
(string __appendtmp9 = "x86_64";) , (_d_arrayappendcTX(ret, 1LU) , ret[ret.length - 1LU] = __appendtmp9 , ret);
return ret;
}
string determineCompiler()
{
return "ldc";
}
toString!2101
{
enum string toString = "2101";
}
_d_arrayappendT!(string, immutable(char))
{
pure nothrow ref @trusted string _d_arrayappendT(return ref scope string x, scope string y)
{
import core.stdc.string : memcpy;
import core.internal.traits : hasElaborateCopyConstructor, Unqual;
import core.lifetime : copyEmplace;
enum bool hasPostblit = false;
ulong length = x.length;
_d_arrayappendcTX(x, y.length);
if (y.length)
{
char* xptr = cast(char*)&x[length];
immutable immutable(ulong) size = 1LU;
memcpy(cast(void*)xptr, cast(const(void*))cast(char*)&y[0], y.length * 1LU);
}
return x;
}
}
_d_arrayappendcTXImpl!(string, immutable(char))
{
import core.internal.array.utils : _d_HookTraceImpl;
private enum string errorMessage = "Cannot append to array if compiling without support for runtime type information!";
pure nothrow ref @trusted string _d_arrayappendcTX(return ref scope string px, ulong n)
{
TypeInfo_Array ti = typeid(string);
byte[] pxx = (cast(byte*)cast(immutable(char)*)px)[0..px.length];
_d_arrayappendcTX(ti, pxx, n);
px = (cast(immutable(char)*)cast(byte*)pxx)[0..pxx.length];
return px;
}
alias _d_arrayappendcTXTrace = auto pure nothrow @trusted string _d_HookTraceImpl(string file, int line, string funcname, return ref scope string _param_3, ulong _param_4)
{
import core.internal.array.utils : gcStatsPure, accumulatePure;
string name = "string";
ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;
try
{
return _d_arrayappendcTX(_param_3, _param_4);
}
finally
{
ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;
if (size > 0LU)
if (!accumulatePure(file, line, funcname, name, size))
{
assert(0);
}
}
}
;
}
_d_HookTraceImpl!(string, _d_arrayappendcTX, "Cannot append to array if compiling without support for runtime type information!")
{
auto pure nothrow @trusted string _d_HookTraceImpl(string file, int line, string funcname, return ref scope string _param_3, ulong _param_4)
{
import core.internal.array.utils : gcStatsPure, accumulatePure;
string name = "string";
ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;
try
{
return _d_arrayappendcTX(_param_3, _param_4);
}
finally
{
ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;
if (size > 0LU)
if (!accumulatePure(file, line, funcname, name, size))
{
assert(0);
}
}
}
}
Parameters!(_d_arrayappendcTX)
{
alias Parameters = (return ref scope string, ulong);
}
FunctionTypeOf!(_d_arrayappendcTX)
{
alias pure nothrow ref @trusted string FunctionTypeOf(return ref scope string px, ulong n);
}
hasElaborateCopyConstructor!(immutable(char))
{
enum bool hasElaborateCopyConstructor = false;
}
Unqual!(immutable(char), char)
{
alias Unqual = char;
}
TraceHook!("string", "_d_arrayappendcTX")
{
const const(char[]) TraceHook = "\n import core.internal.array.utils : gcStatsPure, accumulatePure;\n\n pragma(inline, false);\n string name = `string`;\n\n // FIXME: use rt.tracegc.accumulator when it is accessable in the future.\n version (tracegc)\n {\n\n import core.stdc.stdio;\n\n printf(\"%sTrace file = '%.*s' line = %d function = '%.*s' type = %.*s\\n\",\n \"_d_arrayappendcTX\".ptr,\n file.length, file.ptr,\n line,\n funcname.length, funcname.ptr,\n name.length, name.ptr\n );\n }\n\n ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;\n\n scope(exit)\n {\n ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;\n if (size > 0)\n if (!accumulatePure(file, line, funcname, name, size)) {\n // This 'if' and 'assert' is needed to force the compiler to not remove the call to\n // `accumulatePure`. It really want to do that while optimizing as the function is\n // `pure` and it does not influence the result of this hook.\n\n // `accumulatePure` returns the value of `size`, which can never be zero due to the\n // previous 'if'. So this assert will never be triggered.\n assert(0);\n }\n }\n ";
}
_d_arrayappendcTXImpl!(string[], string)
{
import core.internal.array.utils : _d_HookTraceImpl;
private enum string errorMessage = "Cannot append to array if compiling without support for runtime type information!";
pure nothrow ref @trusted string[] _d_arrayappendcTX(return ref scope string[] px, ulong n)
{
TypeInfo_Array ti = typeid(string[]);
byte[] pxx = (cast(byte*)cast(string*)px)[0..px.length];
_d_arrayappendcTX(ti, pxx, n);
px = (cast(string*)cast(byte*)pxx)[0..pxx.length];
return px;
}
alias _d_arrayappendcTXTrace = auto pure nothrow @trusted string[] _d_HookTraceImpl(string file, int line, string funcname, return ref scope string[] _param_3, ulong _param_4)
{
import core.internal.array.utils : gcStatsPure, accumulatePure;
string name = "string[]";
ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;
try
{
return _d_arrayappendcTX(_param_3, _param_4);
}
finally
{
ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;
if (size > 0LU)
if (!accumulatePure(file, line, funcname, name, size))
{
assert(0);
}
}
}
;
}
_d_HookTraceImpl!(string[], _d_arrayappendcTX, "Cannot append to array if compiling without support for runtime type information!")
{
auto pure nothrow @trusted string[] _d_HookTraceImpl(string file, int line, string funcname, return ref scope string[] _param_3, ulong _param_4)
{
import core.internal.array.utils : gcStatsPure, accumulatePure;
string name = "string[]";
ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;
try
{
return _d_arrayappendcTX(_param_3, _param_4);
}
finally
{
ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;
if (size > 0LU)
if (!accumulatePure(file, line, funcname, name, size))
{
assert(0);
}
}
}
}
Parameters!(_d_arrayappendcTX)
{
alias Parameters = (return ref scope string[], ulong);
}
FunctionTypeOf!(_d_arrayappendcTX)
{
alias pure nothrow ref @trusted string[] FunctionTypeOf(return ref scope string[] px, ulong n);
}
TraceHook!("string[]", "_d_arrayappendcTX")
{
const const(char[]) TraceHook = "\n import core.internal.array.utils : gcStatsPure, accumulatePure;\n\n pragma(inline, false);\n string name = `string[]`;\n\n // FIXME: use rt.tracegc.accumulator when it is accessable in the future.\n version (tracegc)\n {\n\n import core.stdc.stdio;\n\n printf(\"%sTrace file = '%.*s' line = %d function = '%.*s' type = %.*s\\n\",\n \"_d_arrayappendcTX\".ptr,\n file.length, file.ptr,\n line,\n funcname.length, funcname.ptr,\n name.length, name.ptr\n );\n }\n\n ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread;\n\n scope(exit)\n {\n ulong size = gcStatsPure().allocatedInCurrentThread - currentlyAllocated;\n if (size > 0)\n if (!accumulatePure(file, line, funcname, name, size)) {\n // This 'if' and 'assert' is needed to force the compiler to not remove the call to\n // `accumulatePure`. It really want to do that while optimizing as the function is\n // `pure` and it does not influence the result of this hook.\n\n // `accumulatePure` returns the value of `size`, which can never be zero due to the\n // previous 'if'. So this assert will never be triggered.\n assert(0);\n }\n }\n ";
} |
|
I never considered Wasm / other target with this. We should probably expose a way in dub to disable it / hardcode it. |
|
dub shouldn't compile anything other than my project, this feature should be gone, if you need query information about compilers, send PR to dmd/ldc to provide cli option to return information you need |
|
I don't think that'd be easy, and the problem is much bigger than just dub's probe file - any string-concat for CTFE etc. doesn't work anymore in general for such targets with incomplete C bindings in druntime. If the problem here at least is only the |
This is important for CTFE-string-appending etc. for targets without proper druntime support, such as WebAssembly. See ldc-developers/ldc#4324 for an examplary breakage caused by the hook addition in D v2.101, rendering dub totally unusable for such targets. In particular, skip all the `-profile=gc` stuff when not using that cmdline option.
|
I've tested this - not with master, but with #4323. Edit: v1.32 AST with those changes: module dub_platform_probe;
import object;
enum toString(int v) = v.stringof;
string stringArray(string[] ary)
{
string res = null;
{
scope string[] __r3 = ary[];
uint __key2 = 0u;
for (; __key2 < __r3.length; __key2 += 1u)
{
string e = __r3[__key2];
uint i = __key2;
if (i)
_d_arrayappendT(res, ", ");
_d_arrayappendT(res, '"' ~ e ~ '"');
}
}
return res;
}
pragma (msg, "__dub_probe_begin__\n{\n \"compiler\": \"" ~ determineCompiler() ~ "\",\n \"frontendVersion\": 2102,\n \"compilerVendor\": \"LDC\",\n \"platform\": [\n " ~ stringArray(determinePlatform()) ~ "\n ],\n \"architecture\": [\n " ~ stringArray(determineArchitecture()) ~ "\n ],\n}\n__dub_probe_end__");
string[] determinePlatform()
{
string[] ret = null;
(string __appendtmp5 = "wasm";) , (_d_arrayappendcTX(ret, 1u) , ret[ret.length - 1u] = __appendtmp5 , ret);
return ret;
}
string[] determineArchitecture()
{
string[] ret = null;
return ret;
}
string determineCompiler()
{
return "ldc";
}
toString!2102
{
enum string toString = "2102";
}
_d_arrayappendT!(string, immutable(char))
{
pure nothrow ref @trusted string _d_arrayappendT(return ref scope string x, scope string y)
{
import core.stdc.string : memcpy;
import core.internal.traits : hasElaborateCopyConstructor, Unqual;
enum bool hasPostblit = false;
uint length = x.length;
_d_arrayappendcTX(x, y.length);
if (y.length)
{
char* xptr = cast(char*)&x[length];
immutable immutable(uint) size = 1u;
memcpy(cast(void*)xptr, cast(const(void*))cast(char*)&y[0], y.length * 1u);
}
return x;
}
}
_d_arrayappendcTXImpl!(string, immutable(char))
{
import core.internal.array.utils : _d_HookTraceImpl;
private enum string errorMessage = "Cannot append to array if compiling without support for runtime type information!";
pure nothrow ref @trusted string _d_arrayappendcTX(return ref scope string px, uint n)
{
TypeInfo_Array ti = typeid(string);
byte[] pxx = (cast(byte*)cast(immutable(char)*)px)[0..px.length];
_d_arrayappendcTX(ti, pxx, n);
px = (cast(immutable(char)*)cast(byte*)pxx)[0..pxx.length];
return px;
}
version (D_ProfileGC)
{
alias _d_arrayappendcTXTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendcTX, errorMessage)
{
}
;
}
}
hasElaborateCopyConstructor!(immutable(char))
{
enum bool hasElaborateCopyConstructor = false;
}
Unqual!(immutable(char), char)
{
alias Unqual = char;
}
_d_arrayappendcTXImpl!(string[], string)
{
import core.internal.array.utils : _d_HookTraceImpl;
private enum string errorMessage = "Cannot append to array if compiling without support for runtime type information!";
pure nothrow ref @trusted string[] _d_arrayappendcTX(return ref scope string[] px, uint n)
{
TypeInfo_Array ti = typeid(string[]);
byte[] pxx = (cast(byte*)cast(string*)px)[0..px.length];
_d_arrayappendcTX(ti, pxx, n);
px = (cast(string*)cast(byte*)pxx)[0..pxx.length];
return px;
}
version (D_ProfileGC)
{
alias _d_arrayappendcTXTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendcTX, errorMessage)
{
}
;
}
} |
This is important for CTFE-string-appending etc. for targets without proper druntime support, such as WebAssembly. See ldc-developers/ldc#4324 for an examplary breakage caused by the hook addition in D v2.101, rendering dub totally unusable for such targets. In particular, skip all the `-profile=gc` stuff when not using that cmdline option.
|
thanks! |
This is important for CTFE-string-appending etc. for targets without proper druntime support, such as WebAssembly. See #4324 for an examplary breakage caused by the hook addition in D v2.101, rendering dub totally unusable for such targets. In particular, skip all the `-profile=gc` stuff when not using that cmdline option.
|
This was fixed in druntime v2.102 (=> LDC v1.32). |
Hello,
My project no longer build for wasm, i'm not sure i understand why, i made sure no code import modules from libc that isn't in its proper version block for platform specific code
I get the following:
https://gist.github.com/ryuukk/c14e8152b1071baa2ce6fba5f9d11290
How should i debug this?
Why doesn't the compiler tell me what imports it?
Why does the compiler compile code that i supposedly do not use/import?
The text was updated successfully, but these errors were encountered: