Skip to content

Move some middle-end files around#2281

Merged
mshinwell merged 14 commits intoocaml:trunkfrom
mshinwell:middle_end_moves
Apr 1, 2019
Merged

Move some middle-end files around#2281
mshinwell merged 14 commits intoocaml:trunkfrom
mshinwell:middle_end_moves

Conversation

@mshinwell
Copy link
Copy Markdown
Contributor

This pull request contains very little code and is mostly formed of moves tracked by git.

This work has its roots in the gdb support. In that work, having spent a very long time struggling with various problems relating to object file symbols and references thereto, I decided to write patches to change the representation of symbols throughout the compiler. This enables tracking of certain extra information which can be used to check, in the backend, that we are not going outside the envelope of expressions involving symbols that we know to be correctly assembled and resolved across all architectures.

I extracted these symbol-related changes recently with a view to submitting them separately. However it then became clear that due to the complexity of existing code that handles symbols, other refactoring was going to be required first, to provide a coherent story. The main area of attention was the boundary between the middle end and backend, around Compilenv, where there is currently a lot of complexity and code that is hard to understand. I think the integration of Flambda made matters significantly worse here; we should have been more careful (guilty).

The ultimate aim of this patch is to decouple the middle end from the backend. By doing this, we can provide a clean interface, and separate "middle end" types (for example for variables and symbols) from "backend" types. We can then stop passes such as Cmmgen from reaching back into the middle end (the principle from #2280). We share types as appropriate between the Closure and Flambda middle ends; and move code specific to only one of these middle ends into separate files (some of this happens in a subsequent patch). We also remove the necessity to cherry-pick object files from the backend when linking executables such as ocamlobjinfo; the middle-end library will now suffice. A new file_formats/ directory is provided to collect together all of the files representing the formats of compilation artifacts; this seemed on balance like the best approach, given the other possibilities for places for such files to live.

We don't get all the way to the ultimate goal with this GPR alone. A subsequent smaller one, which moves some middle-end code from Asmgen into the middle_end/ directory, and the patch that provides a middle-end-only replacement for Compilenv and changes the symbol types are required for that. However this is the first step along the road.

@chambart Could you please look at this?

@mshinwell
Copy link
Copy Markdown
Contributor Author

@chambart @lthls I'm in the process of rebasing this and fixing the compilation problems.

@mshinwell
Copy link
Copy Markdown
Contributor Author

@chambart @lthls I've pushed a new version of this, extending the scope slightly to cover moving the Lambda language and its passes into a lambda directory at the same time. I think this is a beneficial change and it's probably worth grouping these changes into a single PR, as there will be the potential for stale build artifacts after this has been merged.

I believe I have now fixed up the dune files.

Copy link
Copy Markdown
Contributor

@chambart chambart left a comment

Choose a reason for hiding this comment

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

I can't comment on the dune part but I think this is good to go as soon as the CI is happy.

emit.mlp files for certain other targets; the reference here ensures
that when releases are being prepared the .depend files are correct
for all targets. *)
[@@@ocaml.warning "-66"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was that required ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It appears to be required with the dune build, because I think it sets different warning levels. (I also think it is unfortunate that open! is falling foul of warning 66.)

Copy link
Copy Markdown
Contributor

@lthls lthls left a comment

Choose a reason for hiding this comment

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

The code changes look good, I didn't look into the build system changes in too much depth but if CI passes, it should be fine.

Makefile Outdated
middle_end/base_types asmcomp/debug driver toplevel; \
lambda file_formats middle_end/closure middle_end/flambda \
middle_end/flambda/base_types asmcomp/debug \
driver toplevel; \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@mshinwell
Copy link
Copy Markdown
Contributor Author

If CI passes, this is now ready to merge.

Please be aware that as a result of source files having been moved, stale build artifacts may be left in trees after this PR is merged. I recommend using "git clean -dfx" to clean them out (but beware, this will remove any files that are not tracked by git).

@mshinwell
Copy link
Copy Markdown
Contributor Author

I've rebased this, so let's try again. I have had to disable the ocamldebug and ocamldoc builds under dune because Dynlink is not built correctly. We need to have the dune build follow the same procedure as the make build. For the debugger in particular we cannot use the hack of linking against ocamlcommon instead of Dynlink_compilerlibs due to sharing of the Symtable module. I will work with colleagues to try to get these parts of the dune build resurrected as soon as possible.

@mshinwell mshinwell merged commit 72ea849 into ocaml:trunk Apr 1, 2019
chambart pushed a commit that referenced this pull request May 10, 2019
smuenzel pushed a commit to smuenzel/ocaml that referenced this pull request Jun 26, 2019
jhjourdan added a commit to jhjourdan/ocaml that referenced this pull request Aug 25, 2019
This file is no longer generated since ocaml#2281, and keeping an old one makes make -C utils config.ml
make[1] : on entre dans le répertoire « /home/jjourdan/Travail/soft/ocaml/utils »
sed -e 's!%%AFL_INSTRUMENT%%!false!' \
    -e 's!%%ARCH%%!amd64!' \
    -e 's!%%ARCMD%%!ar!' \
    -e 's!%%ASM%%!as!' \
    -e 's!%%ASM_CFI_SUPPORTED%%!true!' \
    -e 's!%%BYTECCLIBS%%!-lm -ldl  -lpthread !' \
    -e 's!%%CC%%!gcc!' \
    -e 's!%%CCOMPTYPE%%!cc!' \
    -e 's!%%OUTPUTOBJ%%!-o !' \
    -e 's!%%EXT_ASM%%!.s!' \
    -e 's!%%EXT_DLL%%!.so!' \
    -e 's!%%EXE%%!!' \
    -e 's!%%EXT_LIB%%!.a!' \
    -e 's!%%EXT_OBJ%%!.o!' \
    -e 's!%%FLAMBDA%%!false!' \
    -e 's!%%WITH_FLAMBDA_INVARIANTS%%!false!' \
    -e 's!%%FLEXLINK_FLAGS%%!!' \
    -e 's!%%FLEXDLL_DIR%%!!' \
    -e 's!%%HOST%%!x86_64-pc-linux-gnu!' \
    -e 's!%%LIBDIR%%!/usr/local/lib/ocaml!' \
    -e 's!%%LIBUNWIND_AVAILABLE%%!false!' \
    -e 's!%%LIBUNWIND_LINK_FLAGS%%!!' \
    -e 's!%%MKDLL%%!gcc -shared!' \
    -e 's!%%MKEXE%%!gcc -O2 -fno-strict-aliasing -fwrapv -Wall -Werror -fno-tree-vrp -ffunction-sections -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE  -Wl,-E!' \
    -e 's!%%FLEXLINK_LDFLAGS%%! -link \\"-Wl,-E\\"!' \
    -e 's!%%MKMAINDLL%%!gcc -shared!' \
    -e 's!%%MODEL%%!default!' \
    -e 's!%%NATIVECCLIBS%%!-lm -ldl !' \
    -e 's!%%OCAMLC_CFLAGS%%!-O2 -fno-strict-aliasing -fwrapv -fPIC!' \
    -e 's!%%OCAMLC_CPPFLAGS%%!-D_FILE_OFFSET_BITS=64 -D_REENTRANT!' \
    -e 's!%%OCAMLOPT_CFLAGS%%!-O2 -fno-strict-aliasing -fwrapv!' \
    -e 's!%%OCAMLOPT_CPPFLAGS%%!-D_FILE_OFFSET_BITS=64 -D_REENTRANT!' \
    -e 's!%%PACKLD%%!ld -r -o !' \
    -e 's!%%PROFINFO_WIDTH%%!0!' \
    -e 's!%%RANLIBCMD%%!ranlib!' \
    -e 's!%%FORCE_SAFE_STRING%%!false!' \
    -e 's!%%DEFAULT_SAFE_STRING%%!true!' \
    -e 's!%%WINDOWS_UNICODE%%!0!' \
    -e 's!%%SUPPORTS_SHARED_LIBRARIES%%!true!' \
    -e 's!%%SYSTEM%%!linux!' \
    -e 's!%%SYSTHREAD_SUPPORT%%!true!' \
    -e 's!%%TARGET%%!x86_64-pc-linux-gnu!' \
    -e 's!%%WITH_FRAME_POINTERS%%!false!' \
    -e 's!%%WITH_PROFINFO%%!false!' \
    -e 's!%%WITH_SPACETIME%%!false!' \
    -e 's!%%ENABLE_CALL_COUNTS%%!true!' \
    -e 's!%%FLAT_FLOAT_ARRAY%%!true!' \
    -e 's!%%FUNCTION_SECTIONS%%!true!' \
    -e 's!%%CC_HAS_DEBUG_PREFIX_MAP%%!true!' \
    -e 's!%%AS_HAS_DEBUG_PREFIX_MAP%%!true!' \
    config.mlp > config.ml
make[1] : on quitte le répertoire « /home/jjourdan/Travail/soft/ocaml/utils »
./boot/ocamlrun boot/ocamllex -q parsing/lexer.mll produce an invalid  file.

No change entry needed
jhjourdan added a commit to jhjourdan/ocaml that referenced this pull request Aug 25, 2019
This file is no longer generated since ocaml#2281, and keeping an old one
makes `make depend` produce an invalid file.

No change entry needed
dra27 pushed a commit that referenced this pull request Aug 25, 2019
This file is no longer generated since #2281, and keeping an old one
makes `make depend` produce an invalid file.

No change entry needed
gasche added a commit to gasche/ocaml that referenced this pull request Oct 29, 2019
The issue ocaml#9050 comes (partly) from ocaml#2281 forgetting to add the
compilerlibs/ocamlmiddleend archives in the installation target. The
present patch should solve this issue once and for all, by using
a wildcard to install all archives that have been built in
compilerlibs/, instead of using a manual listing.

Compared to trunk, the following extra files are installed in
$(LIBDIR)/compilerlibs: ocamlmiddleend.{a,cma,cmxa}. There are no
other changes in the installed-files list.
gasche added a commit to gasche/ocaml that referenced this pull request Oct 29, 2019
The issue ocaml#9050 comes (partly) from ocaml#2281 forgetting to add the
compilerlibs/ocamlmiddleend archives in the installation target. The
present patch should solve this issue once and for all, by using
a wildcard to install all archives that have been built in
compilerlibs/, instead of using a manual listing.

Compared to trunk, the following extra files are installed in
$(LIBDIR)/compilerlibs: ocamlmiddleend.{a,cma,cmxa}. There are no
other changes in the installed-files list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants