Closed pawelmoll closed 3 weeks ago
// SVInt.h or where the error occurs
// The constructor or function where std::bit_width(value) is called
bitWidth = (bitwidth_t)std::bit_width(static_cast<unsigned char>(value));
Explicit Type Casting: Before calling std::bit_width, you should cast the variable value of type char to unsigned char. This casting is safe and doesn't change the binary representation of the data, but ensures that the type matches the expected input for std::bit_width.
I fixed the build in 3350030c36242709e27ccc6ca342a92f5e988fca but I have no way to check that the tests actually pass on AArch64 hardware.
Thanks a lot for a very quick turnaround! :-)
The code now builds and tests pass all right:
$ git rev-parse HEAD
de7c88b833ed4af529d2557642374c10bd7205bd
$ uname -m
aarch64
$ ctest --output-on-failure
Test project /home/pawmol01/src/slang/build
Start 1: unittests
1/6 Test #1: unittests ........................ Passed 0.75 sec
Start 2: regression_delayed_reg
2/6 Test #2: regression_delayed_reg ........... Passed 0.01 sec
Start 3: regression_wire_module
3/6 Test #3: regression_wire_module ........... Passed 0.01 sec
Start 4: regression_all_file
4/6 Test #4: regression_all_file .............. Passed 0.02 sec
Start 5: netlist_unittests
5/6 Test #5: netlist_unittests ................ Passed 0.02 sec
Start 6: tidy_unittests
6/6 Test #6: tidy_unittests ................... Passed 0.02 sec
100% tests passed, 0 tests failed out of 6
Total Test time (real) = 0.83 sec
$
Also, let me know if you were willing to consider expanding your test infrastructure to cover AArch64 as well.
I'm not against expanding testing to cover AArch64, but I don't think GitHub Actions provides such a runner for public repos? I don't have the time or expertise to figure it out and get it set up but if you wanted to contribute something I'd be happy to accept it.
If you're just using GitHub Actions than the matter is relatively simple - AArch64 runners "are coming". There's already a trial going on for larger, paying customers (https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/) so I'd hope it's just matter of time for them to become business as usual. I'll keep you updated.
Describe the bug Building slang on aarch64 (aka arm64) fails with the following error:
To Reproduce Try building the project on any aarch64 aka arm64 platform. I've tried on Ubuntu 23.10 with g++ 13.2:
but I see no reasons it would behave differently in different distrutions.
Additional context The problem is caused by the following facts:
char
,signed char
andunsigned char
.char
type is signed on x86_64 but unsigned on aarch64.std::bit_width
is only defined forunsigned char
,unsigned short
,unsigned int
,unsigned long
,unsigned long long
.In result, in the following code:
both the
constexpr
conditions evaluate to false andstd::bit_width(char&)
is evaluated resulting with the error.I don't have an immediate solution, because I don't know what is System Verilog's semantic for integer and chars. Perhaps a special case for
std::is_same_v<T, char>
condition or modifying the first case to be triggered by eitherstd::is_signed_v<T> || is_same_v<T, char>
but taking signFlag fromstd:is_signed_v<T>
is the answer?