stdarch icon indicating copy to clipboard operation
stdarch copied to clipboard

Use declarative attribute macros instead of procedural macros for better compile times

Open sayantn opened this issue 1 month ago • 3 comments

Currently, we use 2 procedural macros, assert_instr and simd_test, for testing. It is convenient, but the problem is that it significantly slows down compilation. Seeing that these macros are pretty small, I thought of using declarative attribute macros (rust-lang/rust#143547) instead

The diffcount is huge due to all uses of simd_test being changed, like

#[simd_test(enable = "avx,gfni")]

got changed to

#[simd_test("avx", "gfni")]

The reason being that we cannot do string splitting etc in declarative macros

sayantn avatar Nov 20 '25 02:11 sayantn

The reason being that we cannot do string splitting etc in declarative macros

Wouldn't a split at runtime work fine here?

bjorn3 avatar Nov 20 '25 10:11 bjorn3

No, we need to pass the target features to the std::arch detection macros, and they only accept literals

sayantn avatar Nov 20 '25 10:11 sayantn

for some reason this is actually a little bit slower on my pc. Does anyone know what's going on? I thought proc-macros are supposed to be slower than decl macros in general

sayantn avatar Nov 23 '25 06:11 sayantn