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

Solaris build problem - beam/jit/beam_jit_metadata.cpp:74:8: error: redefinition of ‘struct module_info’ #8024

Closed
psumbera opened this issue Jan 16, 2024 · 2 comments · Fixed by #8038
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@psumbera
Copy link

While building latest version 26.2.1 on Solaris it fails with:

/usr/gcc/13/bin/g++ -DASMJIT_EMBED=1 -DASMJIT_NO_BUILDER=1 -DASMJIT_NO_DEPRECATED=1 -DASMJIT_STATIC=1 -DASMJIT_NO_FOREIGN=1 -Ix86_64-pc-solaris2.11/opt/jit -Ibeam -Isys/unix -Isys/common -Ix86_64-pc-solaris2.11 -Ipcre -Iryu -Iopenssl/include -I../include -I../include/x86_64-pc-solaris2.11 -I../include/internal -I../include/internal/x86_64-pc-solaris2.11 -Ibeam/jit -Ibeam/jit/x86                        \
           -Werror=undef -Werror=return-type -fno-strict-aliasing -fno-common -m64 -fPIC -DPIC -O3 -ffile-prefix-map=/builds/psumbera/userland-erlang/components/erlang=. -DOPENSSL_NO_MD4 -DOPENSSL_NO_RC2 -DOPENSSL_NO_RC4 -I/builds/psumbera/userland-erlang/components/erlang/build/amd64/erts/x86_64-pc-solaris2.11 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -m64 -DHAVE_CONFIG_H -Wall -Wpointer-arith -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_PTHREAD_SEMANTICS -DBEAMASM=1 -m64 -O3 -ffile-prefix-map=/builds/psumbera/userland-erlang/components/erlang=. -fPIC -DPIC -std=c++11 -std=c++17                \
          -include x86_64-pc-solaris2.11/opt/jit/asmjit/asmjit.hpp -c beam/jit/beam_jit_metadata.cpp -o obj/x86_64-pc-solaris2.11/opt/jit/beam_jit_metadata.o
beam/jit/beam_jit_metadata.cpp:74:8: error: redefinition of ‘struct module_info’
   74 | struct module_info {
      |        ^~~~~~~~~~~
In file included from /usr/include/netinet/in.h:66,
                 from sys/unix/erl_unix_sys.h:98,
                 from beam/sys.h:123,
                 from beam/jit/x86/beam_asm.hpp:38,
                 from beam/jit/beam_jit_metadata.cpp:21:
/usr/include/sys/stream.h:221:8: note: previous definition of ‘struct module_info’
  221 | struct module_info {
      |        ^~~~~~~~~~~
beam/jit/beam_jit_metadata.cpp: In function ‘void beamasm_update_gdb_info(std::string, ErtsCodePtr, size_t, const std::vector<AsmRange>&)’:
beam/jit/beam_jit_metadata.cpp:183:18: error: ‘struct module_info’ has no member named ‘base_address’
  183 |     module_info->base_address = (uint64_t)base_address;
      |                  ^~~~~~~~~~~~
beam/jit/beam_jit_metadata.cpp:184:18: error: ‘struct module_info’ has no member named ‘code_size’
  184 |     module_info->code_size = (uint32_t)code_size;
      |                  ^~~~~~~~~
beam/jit/beam_jit_metadata.cpp:185:18: error: ‘struct module_info’ has no member named ‘range_count’
  185 |     module_info->range_count = ranges.size();
      |                  ^~~~~~~~~~~
beam/jit/beam_jit_metadata.cpp:186:18: error: ‘struct module_info’ has no member named ‘name_length’
  186 |     module_info->name_length = module_name.size() + 1;
      |                  ^~~~~~~~~~~
beam/jit/beam_jit_metadata.cpp:187:29: error: ‘struct module_info’ has no member named ‘name’
  187 |     sys_memcpy(module_info->name,
      |                             ^~~~
beam/jit/beam_jit_metadata.cpp:189:29: error: ‘struct module_info’ has no member named ‘name_length’
  189 |                module_info->name_length);
      |                             ^~~~~~~~~~~
beam/jit/beam_jit_metadata.cpp:191:51: error: ‘struct module_info’ has no member named ‘name_length’
  191 |     symfile += sizeof(*debug_info) + module_info->name_length;
      |                                                   ^~~~~~~~~~~

The issue is that Solaris /usr/include/sys/stream.h contains:

/*
 * Module information structure
 */
struct module_info {
        ushort_t mi_idnum;              /* module id number */
        char    *mi_idname;             /* module name */
        ssize_t mi_minpsz;              /* min packet size accepted */
        ssize_t mi_maxpsz;              /* max packet size accepted */
        size_t  mi_hiwat;               /* hi-water mark */
        size_t  mi_lowat;               /* lo-water mark */
};

as workaround I did:

--- otp_src_26.2.1/erts/emulator/beam/jit/beam_jit_metadata.cpp
+++ otp_src_26.2.1/erts/emulator/beam/jit/beam_jit_metadata.cpp
@@ -71,7 +71,7 @@ int frame_layout;
     const void *normal_exit;
 };

-struct module_info {
+struct xmodule_info {
     uint64_t base_address;
     uint32_t range_count;
     uint32_t code_size;
@@ -106,7 +106,7 @@ struct debug_info {
     enum debug_info_header header;
     union {
         struct emulator_info emu;
-        struct module_info mod;
+        struct xmodule_info mod;
     } payload;
 };

Any chance we can upstream something like this?

@psumbera psumbera added the bug Issue is reported as a bug label Jan 16, 2024
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Jan 22, 2024
@jhogberg jhogberg self-assigned this Jan 22, 2024
@jhogberg
Copy link
Contributor

Thanks, I've fixed it in #8038 :)

jhogberg added a commit that referenced this issue Jan 29, 2024
…8940' into maint

* john/erts/avoid-struct-name-crash-solaris/GH-8024/OTP-18940:
  erts: Avoid a struct name clash on Solaris
@jhogberg
Copy link
Contributor

I've merged the fix, thanks again for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants