Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aarch64/fenv.c:41:23: error: invalid initializer #278

Open
ghost opened this issue Jun 1, 2023 · 3 comments · May be fixed by #316
Open

aarch64/fenv.c:41:23: error: invalid initializer #278

ghost opened this issue Jun 1, 2023 · 3 comments · May be fixed by #316

Comments

@ghost
Copy link

ghost commented Jun 1, 2023

Trying to build this for aarch64, and even tried to remove the constant to fix this, but I think I'll open an issue on this. I hope this is just me compiling this incorrectly haha

@ghost
Copy link
Author

ghost commented Jun 1, 2023

Screenshot from 2023-05-31 20-16-45

Apparently even on older releases this still occurs.

@000lbh
Copy link
Contributor

000lbh commented Oct 10, 2024

since fenv_t is a struct, its initializer should be {0}. You can change this line into:
const fenv_t __fe_dfl_env = {0};
However, I have no idea why the original code compiles. On my machine of loongarch64 architecture, it doesn't either.

@giordano
Copy link
Member

giordano commented Jan 9, 2025

There's the same warning on riscv64:

In file included from /home/runner/work/openlibm/openlibm/include/openlibm_fenv.h:18,
                 from src/s_lrint.c:29:
In function ‘feupdateenv’,
    inlined from ‘lrint’ at src/s_lrint.c:59:2:
/home/runner/work/openlibm/openlibm/include/openlibm_fenv_riscv.h:87:25: warning: ‘env’ is used uninitialized [-Wuninitialized]
   87 | #define __wfs(__fcsr)   __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))
      |                         ^~~~~
/home/runner/work/openlibm/openlibm/include/openlibm_fenv_riscv.h:213:9: note: in expansion of macro ‘__wfs’
  213 |         __wfs(*__envp);
      |         ^~~~~
src/s_lrint.c: In function ‘lrint’:
src/s_lrint.c:52:16: note: ‘env’ was declared here
   52 |         fenv_t env;
      |                ^~~

This also makes Julia crash on riscv64 during bootstrap after the update of openlibm to v0.8.4 with the following error message

$ make -j3
[...]
    JULIA usr/lib/julia/sys-o.a
Collecting and executing precompile statements
└ Collect (Basic: ✓ fatal: error thrown and no exception handler available.
BoundsError(a=Array{Base.Partr.taskheap, 1}(dims=(0,), mem=Memory{Base.Partr.taskheap}(0, 0x3f848c0a60)[]), i=(0,))
throw_boundserror at ./essentials.jl:15
getindex at ./essentials.jl:916 [inlined]
getindex at ./abstractarray.jl:1345 [inlined]
multiq_insert at ./partr.jl:152
enq_work at ./task.jl:972
#schedule#589 at ./task.jl:1040
schedule at ./task.jl:1027 [inlined]
notify at ./condition.jl:165
#notify#552 at ./condition.jl:159 [inlined]
notify at ./condition.jl:159 [inlined]
notify at ./condition.jl:159 [inlined]
task_done_hook at ./task.jl:823
unknown function (ip: 0x3f7e650957) at (unknown file)
jl_apply at /home/mose/repo/julia/src/julia.h:2246 [inlined]
jl_finish_task at /home/mose/repo/julia/src/task.c:345
start_task at /home/mose/repo/julia/src/task.c:1292
*** This error is usually fixed by running `make clean`. If the error persists, try `make cleanall`. ***
make[1]: *** [sysimage.mk:99: /home/mose/repo/julia/usr/lib/julia/sys-o.a] Error 1
make: *** [Makefile:120: julia-sysimg-release] Error 2
Command exited with non-zero status 2

On that commit, Julia uses fgetenv/fsetenv inside the task scheduler, which matches the stacktrace. However the use of fenv was removed a few days afterwards, but this still looks to me like a strong indication that the fenv code on riscv64 is bad.

CC: @xctan who introduced this code in #254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants