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

Option -custom-crt should not add MSVC linker option /nodefaultlib:LIBCMT #51

Open
ccuchet opened this issue Feb 2, 2018 · 6 comments

Comments

@ccuchet
Copy link

ccuchet commented Feb 2, 2018

When one wants to use LIBCMT.lib in place of default CRT library MSVCRT.lib, it is not possible with FlexDLL v0.35, because option -custom-crt prevents both to use MSVCRT.lib and LIBCMT.lib.
It should only disable usage of MSVCRT.lib.

See reloc.ml lines 1005-1006:
if !custom_crt then "/nodefaultlib:LIBCMT /nodefaultlib:MSVCRT " ^ extra_args
else "msvcrt.lib " ^ extra_args
should be:
if !custom_crt then "/nodefaultlib:MSVCRT " ^ extra_args
else "msvcrt.lib " ^ extra_args

Thanks

@dra27
Copy link
Member

dra27 commented Feb 2, 2018

Can I ask what your use-case is here? (welcome to GitHub, by the way!)

@alainfrisch - why was -custom-crt added? Of possible relevance, in case your memory is as bad as mine at the moment: https://sympa.inria.fr/sympa/arc/caml-list/2009-07/msg00024.html.

As it happens, I think the fix should possibly go further and not specify either /nodefaultlib, since the reason msvcrt.lib would be pulled in anyway would be because the user was linking objects compiled with cl /MD, so it should really be the caller's responsibility to say -custom-crt (disable flexlink automatically linking with the runtime dll) and then -link /nodefaultlib:msvcrt (prevent the linker automatically adding it in, because I'm linking objects which expected it).

@ccuchet
Copy link
Author

ccuchet commented Feb 2, 2018

Hello

We would like to use LIBCMT and not MSVCRT in an OCaml application.
We compile C files with option '/MT' (not '/MD') and would like to link with LIBCMT.lib (and not MSVCRT.lib).

It is fine if FlexDLL option '-custom-crt' just avoids adding 'msvcrt.lib' and does nothing more.

Thanks

@alainfrisch
Copy link
Collaborator

Yes, my memory is at least as bad as yours. I think -custom-crt was an experiment to allow linking with libcmt, but I never really managed to make it work full scale.

@ccuchet After the suggested fix (or the "going further" variant), are you indeed able to link your OCaml application with libcmt? You probably need to recompile at least the OCaml runtime system, no?

@ccuchet
Copy link
Author

ccuchet commented Feb 2, 2018

Yes we compile the OCaml runtime with option /MT
and after the suggested fix we can link with no errors with LIBCMT.lib
(we do not use dynamic loading of DLL in our application).

@dra27
Copy link
Member

dra27 commented Feb 2, 2018

@ccuchet - thanks for the info! That's pretty that that still works. Did you completely disable native code dynamic linking in your build of OCaml, or are you just not using it?

Would you be willing to create a pull request with the change (if not, Alain or I can do so)?

@ccuchet
Copy link
Author

ccuchet commented Feb 2, 2018

We just do not use dynamic linking.

Can you please do the pull request for me, because I am new with Github and do not want to make mistakes :-)

Thanks

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