www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - How do I make LDC use the stack only?

reply Mateus <m4t3uz outlook.com> writes:
I'm creating a [D operating system 
kernel](https://github.com/m4t3uz/leaf-d). Thread local storage 
(TLS) is not available so it cannot be used. My D kernel compiles 
correctly with DMD but it fails with runtime errors on LDC. I 
guess LDC promotes some stack variables to TLS for example:

```d
void f() {
     ubyte[15] a; // works
     ubyte[16] b; // does not work
     __gshared ubyte[16] c; // works
     MyStruct d; // does not work
}
```

How do I make LDC use the stack only? Should I file a bug report?
Nov 10 2021
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
All of those examples should work. Apart from c which is a global, its 
all on the stack.
Nov 10 2021
prev sibling next sibling parent max haughton <maxhaton gmail.com> writes:
On Thursday, 11 November 2021 at 03:10:48 UTC, Mateus wrote:
 I'm creating a [D operating system 
 kernel](https://github.com/m4t3uz/leaf-d). Thread local storage 
 (TLS) is not available so it cannot be used. My D kernel 
 compiles correctly with DMD but it fails with runtime errors on 
 LDC. I guess LDC promotes some stack variables to TLS for 
 example:

 ```d
 void f() {
     ubyte[15] a; // works
     ubyte[16] b; // does not work
     __gshared ubyte[16] c; // works
     MyStruct d; // does not work
 }
 ```

 How do I make LDC use the stack only? Should I file a bug 
 report?
I Need a definition of what "does not work" means i.e. with output of the error.
Nov 10 2021
prev sibling parent reply Kagamin <spam here.lot> writes:
`b` is likely initialized with sse2 instructions, maybe your 
processor doesn't support sse2.
Nov 11 2021
parent Mateus <m4t3uz outlook.com> writes:
On Thursday, 11 November 2021 at 08:36:37 UTC, Kagamin wrote:
 `b` is likely initialized with sse2 instructions, maybe your 
 processor doesn't support sse2.
the kernel with --march=x86 --mcpu=i386 and it worked! Thank you very much!
Nov 11 2021