Skip to content

Fix building of debug runtime on Windows#820

Merged
damiendoligez merged 2 commits intoocaml:4.04from
dra27:windows-ocamlrund
Oct 4, 2016
Merged

Fix building of debug runtime on Windows#820
damiendoligez merged 2 commits intoocaml:4.04from
dra27:windows-ocamlrund

Conversation

@dra27
Copy link
Member

@dra27 dra27 commented Sep 22, 2016

This fixes the building of ocamlrund.exe and libcamlrun.a/libcamlrun.lib on Windows. To me, each argument for putting this in 4.04 is as strong an argument for putting in trunk instead:

  • The debug runtime is not compiled by default, and the changes (almost) only touch that build path. (The alteration to byterun/.depend.nt compilation is pretty trivial).
  • Although this fixes a broken build system (msvc/msvc64 haven't built since 4.02.2), it's not clear to me that the result is strictly usable. For example, I'm fairly sure that the msvc ports should be installing a .pdb file for ocamlrund.exe (and using the /Fd option to cl to ensure that it has a sensible name).
  • It looks as though compiling libasmrund just got forgotten about when that was added (?), and that isn't here.

FWIW, I'd fix the build system for 4.04 and then aim to improve the debugging support on Windows for 4.05.

Copy link
Member Author

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various notes on the changes

include Makefile.common

CFLAGS=-DOCAML_STDLIB_DIR='"$(LIBDIR)"' $(IFLEXDIR)
DFLAGS=$(CFLAGS) -DDEBUG
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humorously, only the msvc64 Makefile actually defined DEBUG, so the ocamlrund.exe built in the other ports was in fact just a standard runtime!
Defining DFLAGS is vaguely as done in Makefile


ocamlrund$(EXE): libcamlrund.$(A) prims.$(O) main.$(O)
$(MKEXE) -o ocamlrund$(EXE) $(BYTECCDBGCOMPOPTS) prims.$(O) \
$(MKEXE) -o ocamlrund$(EXE) prims.$(O) \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes no sense to include $(BYTECCDBGCOMPOPTS) here (unsurprisingly, flexlink doesn't like the extra arguments).

>> .depend.win32
cat .depend >> .depend.win32
sed -e '/\.d\.o/q' -e 's/^\(.*\)\.o:/\1.$$(O) \1.$$(DBGO):/' \
sed -ne '/\.pic\.o/q' \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using -n means that there isn't a stray .pic.o line at the bottom, hence the -e p at the end (or there'd be no lines at all...)

sed -e '/\.d\.o/q' -e 's/^\(.*\)\.o:/\1.$$(O) \1.$$(DBGO):/' \
sed -ne '/\.pic\.o/q' \
-e 's/^\(.*\)\.d\.o:/\1.$$(DBGO):/' \
-e 's/^\(.*\)\.o:/\1.$$(O):/' \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never worked - interp.o has additional dependencies when compiled for debug mode.

BYTECCCOMPOPTS=-O2 -Gy- -MD

### Additional compile-time options for $(BYTECC). (For debug version.)
BYTECCDBGCOMPOPTS=-DDEBUG -Zi -W3 -Wp64
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Wp64 was deprecated a loooong time ago - /W4 replaces it now. -W3 causes a vast number of warnings to be displayed.

Copy link
Member

@damiendoligez damiendoligez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of including this in 4.04, as the risk is null for other ports, and very low for the Windows ports.

BYTECCDBGCOMPOPTS=-g

### Flag to use to rename object files. (for debug version.)
NAME_OBJ_FLAG=-o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. I think you need a space at the end of the variable's value. Here is how to do it:

EMPTY=
SPACE=$(EMPTY) $(EMPTY)
BYTECCDBGCOMPOPTS=-o$(SPACE)

You might want to pull the definitions of EMPTY and SPACE to the beginning of the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it does work (and is POSIX), but GCC's command line doesn't use the normal GNU long option conventions (with the knock-on effect that you cannot say, for example, gcc -cv to mean gcc -c -v).

If GCC were to add a non-standard long option beginning with o (say, -ofoo) in the future then this would become a problem - however, GCC does add new options using --long-option syntax.

However, would you prefer it changed as you show just for neatness of the command line printed by make? The only reason I didn't do it that way was because it isn't strictly necesssary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, gcc accepts -omyprogram.exe, so maybe Damien's space dance is not necessary.

Another way to deal with those space-or-not-space issues is to define macros that take parameters and are to be invoked via $(call...), like MKLIB or MAKE_OCAMLRUN.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I debated using a macro but, in a very uncharacteristic twist for me, kept it simpler 😉

BYTECCDBGCOMPOPTS=-g

### Flag to use to rename object files. (for debug version.)
NAME_OBJ_FLAG=-o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as above about the space.

BYTECCDBGCOMPOPTS=-Zi

### Flag to use to rename object files. (for debug version.)
NAME_OBJ_FLAG=/Fo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use a / for this option when all the others are using - ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I find the use of - with MS tools looks weird 😄 It's a careless over-sight which I'll correct!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I vaguely remember some recent Microsoft C compilers warning about the use of "-o" instead of "/Fo"... Or was it for "/Fe" ? (executable name?).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-o is indeed deprecated, but it's a synonym for /Fe - it was erroneously (well, accidentally is probably fairer) used as though it meant /Fo when building ocamlrund.

BYTECCDBGCOMPOPTS=-Zi

### Flag to use to rename object files. (for debug version.)
NAME_OBJ_FLAG=/Fo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about / vs -

@damiendoligez damiendoligez added this to the 4.04 milestone Sep 29, 2016
@shayne-fletcher
Copy link
Contributor

On Oct 1, 2016 2:16 PM, "Xavier Leroy" [email protected] wrote:

@xavierleroy commented on this pull request.


In config/Makefile.msvc:

@@ -94,6 +94,12 @@ BYTECC=cl -nologo -D_CRT_SECURE_NO_DEPRECATE ###
Additional compile-time options for $(BYTECC). (For static linking.)
BYTECCCOMPOPTS=-O2 -Gy- -MD +### Additional compile-time options for
$(BYTECC). (For debug version.) +BYTECCDBGCOMPOPTS=-Zi + +### Flag to use
to rename object files. (for debug version.) +NAME_OBJ_FLAG=/Fo

Actually I vaguely remember some recent Microsoft C compilers warning
about the use of "-o" instead of "/Fo"... Or was it for "/Fe" ? (executable
name?).

No, as I recall you are correct and /Fe is where the executable name is
specified.

dra27 added 2 commits October 1, 2016 22:37
f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.
Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
@dra27 dra27 force-pushed the windows-ocamlrund branch from 9d135fe to d59cace Compare October 1, 2016 21:39
@dra27
Copy link
Member Author

dra27 commented Oct 1, 2016

Rebased and /Fo changed to -Fo

@damiendoligez damiendoligez merged commit 6b46d4a into ocaml:4.04 Oct 4, 2016
@damiendoligez damiendoligez mentioned this pull request Oct 7, 2016
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 10, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 10, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 11, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 11, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 12, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit to dra27/ocaml that referenced this pull request Dec 14, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
dra27 added a commit that referenced this pull request Dec 14, 2016
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
camlspotter pushed a commit to camlspotter/ocaml that referenced this pull request Oct 17, 2017
* Fix compilation of debug objects on MSVC

f22564 (0f1669 for 4.02) changed the way debugging objects are compiled
to allow parallelisation. Unfortunately, this was introduced in a way
which doesn't work for the Microsoft C Compiler where -o is deprecated
alias of /Fe and doesn't ever mean /Fo.

* Fix Windows compilation of ocamlrund/libcamlrund

Fixes various problems with compiling ocamlrund on Windows - most
notably the fact that only msvc64 actually activated debug mode!
@dra27 dra27 deleted the windows-ocamlrund branch July 6, 2021 14:05
kayceesrk added a commit to ocaml-multicore/ocaml that referenced this pull request Dec 24, 2021
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Sep 21, 2022
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Sep 21, 2022
I confirmed this test fails on a version of the compiler with the bug.
sadiqj pushed a commit to sadiqj/ocaml that referenced this pull request Feb 21, 2023
sadiqj pushed a commit to sadiqj/ocaml that referenced this pull request Feb 21, 2023
…g) (ocaml#841)

I confirmed this test fails on a version of the compiler with the bug.
stedolan pushed a commit to stedolan/ocaml that referenced this pull request Mar 21, 2023
25188da flambda-backend: Missed comment from PR802 (ocaml#887)
9469765 flambda-backend: Improve the semantics of asynchronous exceptions (new simpler version) (ocaml#802)
d9e4dd0 flambda-backend: Fix `make runtest` on NixOS (ocaml#874)
4bbde7a flambda-backend: Simpler symbols (ocaml#753)
ef37262 flambda-backend: Add opaqueness to Obj.magic under Flambda 2 (ocaml#862)
a9616e9 flambda-backend: Add build system hooks for ocaml-jst (ocaml#869)
045ef67 flambda-backend: Allow the compiler to build with stock Dune (ocaml#868)
3cac5be flambda-backend: Simplify Makefile logic for natdynlinkops (ocaml#866)
c5b12bf flambda-backend: Remove unnecessary install lines (ocaml#860)
ff12bbe flambda-backend: Fix unused variable warning in st_stubs.c (ocaml#861)
c84976c flambda-backend: Static check for noalloc: attributes (ocaml#825)
ca56052 flambda-backend: Build system refactoring for ocaml-jst (ocaml#857)
39eb7f9 flambda-backend: Remove integer comparison involving nonconstant polymorphic variants (ocaml#854)
c102688 flambda-backend: Fix soundness bug by using currying information from typing (ocaml#850)
6a96b61 flambda-backend: Add a primitive to enable/disable the tick thread (ocaml#852)
f64370b flambda-backend: Make Obj.dup use a new primitive, %obj_dup (ocaml#843)
9b78eb2 flambda-backend: Add test for ocaml#820 (include functor soundness bug) (ocaml#841)
8f24346 flambda-backend: Add `-dtimings-precision` flag (ocaml#833)
65c2f22 flambda-backend: Add test for ocaml#829 (ocaml#831)
7b27a49 flambda-backend: Follow-up PR#829 (comballoc fixes for locals) (ocaml#830)
ad7ec10 flambda-backend: Use a custom condition variable implementation (ocaml#787)
3ee650c flambda-backend: Fix soundness bug in include functor (ocaml#820)
2f57378 flambda-backend: Static check noalloc (ocaml#778)
aaad625 flambda-backend: Emit begin/end region only when stack allocation is enabled (ocaml#812)
17c7173 flambda-backend: Fix .cmt for included signatures (ocaml#803)
e119669 flambda-backend: Increase delays in tests/lib-threads/beat.ml (ocaml#800)
ccc356d flambda-backend: Prevent dynamic loading of the same .cmxs twice in private mode, etc. (ocaml#784)
14eb572 flambda-backend: Make local extension point equivalent to local_ expression (ocaml#790)
487d11b flambda-backend: Fix tast_iterator and tast_mapper for include functor. (ocaml#795)
a50a818 flambda-backend: Reduce closure allocation in List (ocaml#792)
96c9c60 flambda-backend: Merge ocaml-jst
a775b88 flambda-backend: Fix ocaml/otherlibs/unix 32-bit build (ocaml#767)
f7c2679 flambda-backend: Create object files internally to avoid invoking GAS (ocaml#757)
c7a46bb flambda-backend: Bugfix for Cmmgen.expr_size with locals (ocaml#756)
b337cb6 flambda-backend: Fix build_upstream for PR749 (ocaml#750)
8e7e81c flambda-backend: Differentiate is_int primitive between generic and variant-only versions (ocaml#749)

git-subtree-dir: ocaml
git-subtree-split: 25188da
OlivierNicole pushed a commit to OlivierNicole/ocaml that referenced this pull request Jul 28, 2025
…#841)

I confirmed this test fails on a version of the compiler with the bug.
OlivierNicole pushed a commit to OlivierNicole/ocaml that referenced this pull request Jul 28, 2025
…#841)

I confirmed this test fails on a version of the compiler with the bug.
OlivierNicole pushed a commit to OlivierNicole/ocaml that referenced this pull request Aug 1, 2025
…#841)

I confirmed this test fails on a version of the compiler with the bug.
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 this pull request may close these issues.

4 participants