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

Enabling (use_standard_c_and_cxx_flags) fails when paired with C++ stubs on Windows #8643

Open
kit-ty-kate opened this issue Sep 13, 2023 · 5 comments

Comments

@kit-ty-kate
Copy link
Member

Expected Behavior

For (foreign_stubs (language cxx) ...) to work on Windows

Actual Behavior

Flexlink fails with "Does not know about the -shared-libgcc argument"

Reproduction

  1. Create a library with a C++ foreign stubs
  2. Build it on Windows (MinGW)

Specifications

  • Version of dune (output of dune --version): 3.5.0
  • Version of ocaml (output of ocamlc --version): 4.14.1
  • Operating system (distribution and version): Windows / x86_64 / MinGW
@rgrinberg
Copy link
Member

What does ocamlc -config say on this system?

@kit-ty-kate
Copy link
Member Author

version: 4.14.1
standard_library_default: C:/cygwin64/home/Kate/opam/bootstrap/ocaml/lib/ocaml
standard_library: C:/cygwin64/home/Kate/opam/bootstrap/ocaml/lib/ocaml
ccomp_type: cc
c_compiler: x86_64-w64-mingw32-gcc
ocamlc_cflags: -O2 -fno-strict-aliasing -fwrapv -mms-bitfields
ocamlc_cppflags:
ocamlopt_cflags: -O2 -fno-strict-aliasing -fwrapv -mms-bitfields
ocamlopt_cppflags:
bytecomp_c_compiler: x86_64-w64-mingw32-gcc -O2 -fno-strict-aliasing -fwrapv -mm
s-bitfields
native_c_compiler: x86_64-w64-mingw32-gcc -O2 -fno-strict-aliasing -fwrapv -mms-
bitfields
bytecomp_c_libraries: -lws2_32 -lversion
native_c_libraries: -lws2_32 -lversion
native_pack_linker: x86_64-w64-mingw32-ld -r -o
architecture: amd64
model: default
int_size: 63
word_size: 64
system: mingw64
asm: x86_64-w64-mingw32-gcc -c
asm_cfi_supported: false
with_frame_pointers: false
ext_exe: .exe
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .dll
os_type: Win32
default_executable_name: camlprog.exe
systhread_supported: true
host: x86_64-w64-mingw32
target: x86_64-w64-mingw32
flambda: false
safe_string: true
default_safe_string: true
flat_float_array: true
function_sections: false
afl_instrument: false
windows_unicode: true
supports_shared_libraries: true
naked_pointers: true
exec_magic_number: Caml1999X031
cmi_magic_number: Caml1999I031
cmo_magic_number: Caml1999O031
cma_magic_number: Caml1999A031
cmx_magic_number: Caml1999Y031
cmxa_magic_number: Caml1999Z031
ast_impl_magic_number: Caml1999M031
ast_intf_magic_number: Caml1999N031
cmxs_magic_number: Caml1999D031
cmt_magic_number: Caml1999T031
linear_magic_number: Caml1999L031

@rgrinberg
Copy link
Member

No idea, sorry. What's the version of mingw here?

@nojb any idea why mingw doesn't like this option?

@nojb
Copy link
Collaborator

nojb commented Sep 25, 2023

No idea, sorry. What's the version of mingw here?

@nojb any idea why mingw doesn't like this option?

I am far from an expert, but on Windows, my believe that libgcc is linked dynamically by default, so perhaps this flag just does not exist. Just omitting the flag may be a first step to make it work (but maybe other steps are needed).

@kit-ty-kate
Copy link
Member Author

the problem is that on Windows with flexlink, it is flexlink that is called as the linker by the compiler, not gcc directly. -shared-libgcc is not a correct option of flexlink and any option that is meant to be given to gcc instead has to have the -Wl, prefix instead (e.g. -Wl,-the-option).

mefyl pushed a commit to mefyl/timmy that referenced this issue Aug 1, 2024
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

No branches or pull requests

3 participants