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

erts: Do not annotate nif API functions on windows #9016

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

garazdawi
Copy link
Contributor

On windows nifs can be compiled with gcc/clang which means that __has_attribute(malloc) is defined. This was never intended to work so we disable it on Windows.

closes #9015

@garazdawi garazdawi added team:VM Assigned to OTP team VM fix labels Nov 4, 2024
@garazdawi garazdawi requested a review from sverker November 4, 2024 20:47
@garazdawi garazdawi self-assigned this Nov 4, 2024
Copy link
Contributor

github-actions bot commented Nov 4, 2024

CT Test Results

    3 files    141 suites   48m 40s ⏱️
1 596 tests 1 547 ✅ 49 💤 0 ❌
2 305 runs  2 236 ✅ 69 💤 0 ❌

Results for commit 1b31fb0.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

On windows nifs can be compiled with gcc/clang which
means that __has_attribute(malloc) is defined. This
was never intended to work so we disable it on Windows.

closes erlang#9015
@garazdawi garazdawi force-pushed the lukas/erts/windows-gcc-nifs branch from 40fa3de to 4ae3182 Compare November 4, 2024 21:05
@essen
Copy link
Contributor

essen commented Nov 5, 2024

This fixes the build in many of my test cases. I do get some warnings remaining:

In file included from C:/msys64/home/essen/ninenines/erlang.mk/test/test_c_src_makefile_change/c_src/test_c_src_makefile_change.c:1:
C:/msys64/home/essen/ninenines/erlang.mk/test/test_c_src_makefile_change/c_src/test_c_src_makefile_change.c: In function 'nif_init':
c:/erl28.0-rc0/erts-15.1.2/include/erl_nif.h:379:29: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
  379 | #  define ERL_NIF_INIT_BODY memcpy(&WinDynNifCallbacks,callbacks,sizeof(TWinDynNifCallbacks))
      |                             ^~~~~~
c:/erl28.0-rc0/erts-15.1.2/include/erl_nif.h:440:5: note: in expansion of macro 'ERL_NIF_INIT_BODY'
  440 |     ERL_NIF_INIT_BODY;                  \
      |     ^~~~~~~~~~~~~~~~~
C:/msys64/home/essen/ninenines/erlang.mk/test/test_c_src_makefile_change/c_src/test_c_src_makefile_change.c:51:1: note: in expansion of macro 'ERL_NIF_INIT'
   51 | ERL_NIF_INIT(test_c_src_makefile_change, nif_funcs, load, NULL, upgrade, unload)
      | ^~~~~~~~~~~~
c:/erl28.0-rc0/erts-15.1.2/include/erl_nif.h:379:29: warning: incompatible implicit declaration of built-in function 'memcpy'
  379 | #  define ERL_NIF_INIT_BODY memcpy(&WinDynNifCallbacks,callbacks,sizeof(TWinDynNifCallbacks))
      |                             ^~~~~~
c:/erl28.0-rc0/erts-15.1.2/include/erl_nif.h:440:5: note: in expansion of macro 'ERL_NIF_INIT_BODY'
  440 |     ERL_NIF_INIT_BODY;                  \
      |     ^~~~~~~~~~~~~~~~~
C:/msys64/home/essen/ninenines/erlang.mk/test/test_c_src_makefile_change/c_src/test_c_src_makefile_change.c:51:1: note: in expansion of macro 'ERL_NIF_INIT'
   51 | ERL_NIF_INIT(test_c_src_makefile_change, nif_funcs, load, NULL, upgrade, unload)
      | ^~~~~~~~~~~~
C:/msys64/home/essen/ninenines/erlang.mk/test/test_c_src_makefile_change/c_src/test_c_src_makefile_change.c:2:1: note: include '<string.h>' or provide a declaration of 'memcpy'
    1 | #include "erl_nif.h"
  +++ |+#include <string.h>
    2 |

@garazdawi
Copy link
Contributor Author

I pushed another commit, please try it out and see if it helps.

@essen
Copy link
Contributor

essen commented Nov 5, 2024

I am not seeing warnings anymore. Thank you!

I will wait for the next OTP-27 release that contains this before I enable Windows in CI again because testing using custom installers is a bit of a PITA. Would be great if setup-beam could use them.

@garazdawi garazdawi added the testing currently being tested, tag is used by OTP internal CI label Nov 6, 2024
@garazdawi garazdawi merged commit f1d8c26 into erlang:master Nov 7, 2024
21 checks passed
@garazdawi garazdawi added this to the OTP-27.2 milestone Nov 7, 2024
@garazdawi garazdawi deleted the lukas/erts/windows-gcc-nifs branch November 7, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NIFs fail to compile on Windows
3 participants