Local variable requires a valid scope

I have an unusual situation where the code in my project compiles and runs correctly in Debug, ReleaseSafe, and ReleaseFast. However, compiling for ReleaseSmall always causes the error:

local variable requires a valid scope

and the compiler aborts with a Segmentation fault. This is version 0.14.0 although I believe the problem arose sometime during the 0.14-dev cycle.
The compile target is:

const platform_target = std.Build.parseTargetQuery(.{
        .arch_os_abi = "thumb-freestanding-eabihf",
        .cpu_features = "cortex_m4+strict_align+vfp4d16sp",
}) catch @panic("failed to parse platform target");

The failure also occurs with just: .cpu_features = "cortex_m4".

I have searched around and tried to reproduce the error with a minimal file, but have not been successful in that. The code is quite low level, contains exported functions and specific linker section directives. It is start up and device code. The compiler binary does indeed contain the error string, but since the pre-compiled binaries are distributed without symbolic information, I’m a bit lost as to how to proceed.

Has anyone else encountered this problem? Any suggestions on how to proceed?

1 Like

It’s tedious, but maybe compile the Zig compiler binary in Debug/ReleaseSafe mode and git bisect to figure out which commit to the compiler caused it.

Thanks. That was about where I had arrived. It is a regression from 0.13,0 so that puts some bounds on the problem. And I suppose it would not hurt me to learn to build the compiler from source. I’ll probably spend a bit more time to see if I can come up with a minimal failing example. Otherwise, sometimes you just have to roll up your sleeves and dig in.