February 23, 2023 [Issue 23729] ignore custom object.d for CTFE needs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23729 --- Comment #9 from ryuukk_ <ryuukk.dev@gmail.com> --- Here a minimal reduced reproducer: ``` --- main.d extern(C) void main() { mixin (simpleFormat(q{ asm pure nothrow @nogc @trusted { naked; ret; } }, [])); } string simpleFormat(string format, scope string[] args) { string result; outer: while (format.length) { foreach (i; 0 .. format.length) { if (format[i] == '%' || format[i] == '?') { bool isQ = format[i] == '?'; result ~= format[0 .. i++]; assert (i < format.length, "Invalid format string"); if (format[i] == '%' || format[i] == '?') { assert(!isQ, "Invalid format string"); result ~= format[i++]; } else { int index = 0; assert (format[i] >= '0' && format[i] <= '9', "Invalid format string"); while (i < format.length && format[i] >= '0' && format[i] <= '9') index = index * 10 + (ubyte(format[i++]) - ubyte('0')); if (!isQ) result ~= args[index]; else if (!args[index]) { size_t j = i; for (; j < format.length;) { if (format[j++] == '\n') break; } i = j; } } format = format[i .. $]; continue outer; } } result ~= format; break; } return result; } --- object.d module object; pragma(msg, "-- using custom runtime --"); alias size_t = typeof(int.sizeof); alias ptrdiff_t = typeof(cast(void*)0 - cast(void*)0); alias noreturn = typeof(*null); alias string = immutable(char)[]; alias wstring = immutable(wchar)[]; alias dstring = immutable(dchar)[]; -- |
February 23, 2023 [Issue 23729] ignore custom object.d for CTFE needs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23729 --- Comment #10 from Dennis <dkorpel@live.nl> --- > dmd shouldn't use my object.d, it has nothing to do with COMPILING the program, therefore it is a bug The druntime and phobos sources are not hardwired into the compiler, they are found using the same lookup mechanism as other d source files, where the current working directory is the first import path. If you don't want the compiler to use your own object.d as the implicitly imported module and source of druntime hooks, then you should name it something else. However, it's clear that you fully intend to replace object.d because you want a custom runtime, so that's not the solution. > So it is a bug in the compiler, because he don't understand that DMD should use its object.d, not mine Okay, let's say we add a special rule that object.d is only found in the installation's druntime folder. Then you don't have your custom lightweight runtime anymore, and all WASM incompatible dependencies are still dragged in. So what you really want is that your own object.d is used for 'code generation purposes', and the official object.d is used for 'CTFE purposes'. That's completely intractable. No compiler developer, let alone D user, is going to understand how that works. I don't see anything actionable in this issue, apart from making the druntime more pay as you go. That has long been a goal already, and would obviate the need for a custom lightweight druntime in the first place. But that's not a bug you can fix in an afternoon. -- |
February 24, 2023 [Issue 23729] ignore custom object.d for CTFE needs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23729 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |INVALID --- Comment #11 from RazvanN <razvan.nitu1305@gmail.com> --- As stated before, this is not a bug. The compiler is working as intended, it's just that you are replacing the custom object.d with different one. If you want the compiler to not take into account your implementation of object, just name it something else, or put it in a different directory. -- |
Copyright © 1999-2021 by the D Language Foundation