Skip to content

Cleanup formatting #799

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ocamlformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ jobs:
- name: Install ocamlformat 0.19.0
run: opam pin -y ocamlformat 0.19.0

- name: Checkout dune github repo
uses: actions/checkout@master
with:
repository: 'ocaml-flambda/dune'
ref: 'special_dune'
path: 'dune'

- name: Build dune
working-directory: dune
run: |
opam exec -- make release

- name: autoconf
working-directory: flambda_backend
run: autoconf
Expand All @@ -39,8 +51,8 @@ jobs:
./configure \
--prefix=$GITHUB_WORKSPACE/_install \
--enable-middle-end=closure \
--with-dune=/bin/false
--with-dune=$GITHUB_WORKSPACE/dune/dune.exe

- name: Check formatting of Flambda 2 and Cfg code
- name: Check formatting
working-directory: flambda_backend
run: opam exec -- make check-fmt
1 change: 0 additions & 1 deletion backend/.ocamlformat → .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Please make a pull request to change this file.
disable=true
# There is an .ocamlformat-enable file in this directory.
# Keep the remainder of this file in sync with other .ocamlformat files in this repo.
assignment-operator=begin-line
cases-exp-indent=2
doc-comments=before
Expand Down
15 changes: 15 additions & 0 deletions .ocamlformat-enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
middle_end/mangling.ml
middle_end/mangling.mli
middle_end/flambda2/**/*.ml
middle_end/flambda2/**/*.mli
backend/cmm_helpers.ml
backend/cmm_helpers.mli
backend/internal_assembler/*.ml
backend/internal_assembler/*.mli
backend/cfg/**/*.ml
backend/cfg/**/*.mli
backend/asm_targets/**/*.ml
backend/asm_targets/**/*.mli
backend/debug/**/*.ml
backend/debug/**/*.mli
tools/merge_archives.ml
41 changes: 4 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,51 +361,18 @@ promote:
$(dune) promote $(ws_main)

.PHONY: fmt
fmt:
ocamlformat -i \
$$(find middle_end/flambda2 \
\( -name "*.ml" -or -name "*.mli" \) \
-and \! \( -name "flambda_parser.*" -or -name "flambda_lex.*" \))
ocamlformat -i \
$$(find backend/cfg \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i middle_end/mangling.ml
ocamlformat -i middle_end/mangling.mli
ocamlformat -i \
$$(find backend/asm_targets \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i \
$$(find backend/debug \
\( -name "*.ml" -or -name "*.mli" \))
ocamlformat -i backend/cmm_helpers.ml{,i}
ocamlformat -i tools/merge_archives.ml
ocamlformat -i \
$$(find backend/debug/dwarf \
\( -name "*.ml" -or -name "*.mli" \))
fmt: duneconf/main.ws
$(dune) build $(ws_main) @fmt --auto-promote

.PHONY: check-fmt
check-fmt:
@if [ "$$(git status --porcelain middle_end/flambda2)" != "" ] || \
[ "$$(git status --porcelain backend/cfg)" != "" ] || \
[ "$$(git status --porcelain middle_end/mangling.ml)" != "" ] || \
[ "$$(git status --porcelain middle_end/mangling.mli)" != "" ] || \
[ "$$(git status --porcelain backend/asm_targets)" != "" ] || \
[ "$$(git status --porcelain backend/debug)" != "" ] || \
[ "$$(git status --porcelain backend/cmm_helpers.ml{,i})" != "" ] || \
[ "$$(git status --porcelain tools/merge_archives.ml)" != "" ]; then \
@if [ "$$(git status --porcelain)" != "" ] ; then \
echo; \
echo "Tree must be clean before running 'make check-fmt'"; \
exit 1; \
fi
$(MAKE) fmt
@if [ "$$(git diff middle_end/flambda2)" != "" ] || \
[ "$$(git diff backend/cfg)" != "" ] || \
[ "$$(git diff middle_end/mangling.ml)" != "" ] || \
[ "$$(git diff middle_end/mangling.mli)" != "" ] || \
[ "$$(git diff backend/asm_targets)" != "" ] || \
[ "$$(git diff backend/debug)" != "" ] || \
[ "$$(git diff backend/cmm_helpers.ml{,i})" != "" ] || \
[ "$$(git diff tools/merge_archives.ml)" != "" ]; then \
@if [ "$$(git diff)" != "" ]; then \
echo; \
echo "The following code was not formatted correctly:"; \
echo "(the + side of the diff is how it should be formatted)"; \
Expand Down
10 changes: 0 additions & 10 deletions backend/.ocamlformat-enable

This file was deleted.

10 changes: 5 additions & 5 deletions backend/asm_targets/dune
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(include_subdirs unqualified)

(library
(name asm_targets)
(wrapped true)
(flags (:standard -principal))
(libraries ocamlcommon dwarf_flags)
)
(name asm_targets)
(wrapped true)
(flags
(:standard -principal))
(libraries ocamlcommon dwarf_flags))
13 changes: 7 additions & 6 deletions backend/debug/dwarf/dwarf_flags/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(include_subdirs unqualified)

(library
(name dwarf_flags)
(wrapped true)
(flags (:standard -principal))
(ocamlopt_flags (:standard -O3))
(libraries ocamlcommon)
)
(name dwarf_flags)
(wrapped true)
(flags
(:standard -principal))
(ocamlopt_flags
(:standard -O3))
(libraries ocamlcommon))
13 changes: 7 additions & 6 deletions backend/debug/dwarf/dwarf_high/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(include_subdirs unqualified)

(library
(name dwarf_high)
(wrapped true)
(flags (:standard -principal))
(ocamlopt_flags (:standard -O3))
(libraries dwarf_low asm_targets)
)
(name dwarf_high)
(wrapped true)
(flags
(:standard -principal))
(ocamlopt_flags
(:standard -O3))
(libraries dwarf_low asm_targets))
13 changes: 7 additions & 6 deletions backend/debug/dwarf/dwarf_low/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(include_subdirs unqualified)

(library
(name dwarf_low)
(wrapped true)
(flags (:standard -principal))
(ocamlopt_flags (:standard -O3))
(libraries asm_targets)
)
(name dwarf_low)
(wrapped true)
(flags
(:standard -principal))
(ocamlopt_flags
(:standard -O3))
(libraries asm_targets))
13 changes: 7 additions & 6 deletions backend/debug/dwarf/dwarf_ocaml/dune
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(include_subdirs unqualified)

(library
(name dwarf_ocaml)
(wrapped true)
(flags (:standard -principal))
(ocamlopt_flags (:standard -O3))
(libraries dwarf_high dwarf_low asm_targets)
)
(name dwarf_ocaml)
(wrapped true)
(flags
(:standard -principal))
(ocamlopt_flags
(:standard -O3))
(libraries dwarf_high dwarf_low asm_targets))
31 changes: 17 additions & 14 deletions backend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@

(rule
(targets arch.ml CSE.ml proc.ml reload.ml scheduling.ml selection.ml)
(mode fallback)
(deps (glob_files amd64/*.ml)
(glob_files arm64/*.ml))
(action (bash "cp %{env:ARCH=amd64}/*.ml .")))
(mode fallback)
(deps
(glob_files amd64/*.ml)
(glob_files arm64/*.ml))
(action
(bash "cp %{env:ARCH=amd64}/*.ml .")))

(rule
(targets emit.ml)
(mode fallback)
(deps amd64/emit.mlp
arm64/emit.mlp)
(mode fallback)
(deps amd64/emit.mlp arm64/emit.mlp)
(action
(progn
(with-stdout-to contains-input-name
(bash "echo %{env:ARCH=amd64}/emit.mlp"))
(with-stdout-to %{targets}
(progn
(bash "echo \\# 1 \\\"`cat contains-input-name`\\\"")
(bash "%{dep:../ocaml/tools/cvt_emit.exe} < `cat contains-input-name`"))))))
(progn
(with-stdout-to
contains-input-name
(bash "echo %{env:ARCH=amd64}/emit.mlp"))
(with-stdout-to
%{targets}
(progn
(bash "echo \\# 1 \\\"`cat contains-input-name`\\\"")
(bash "%{dep:../ocaml/tools/cvt_emit.exe} < `cat contains-input-name`"))))))
3 changes: 2 additions & 1 deletion backend/internal_assembler/internal_assembler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ let create_relocation_tables compiler_sections symbol_table string_table =
(Section_name.Map.bindings compiler_sections)

let write buf header section_table symbol_table relocation_tables string_table =
Compiler_owee.Owee_elf.write_elf buf header (Section_table.get_sections section_table);
Compiler_owee.Owee_elf.write_elf buf header
(Section_table.get_sections section_table);
Section_table.write_bodies section_table buf;
let symtab =
Section_table.get_section section_table
Expand Down
6 changes: 5 additions & 1 deletion backend/internal_assembler/section_table.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ type t
val create : unit -> t

val add_section :
t -> X86_proc.Section_name.t -> ?body:bytes -> Compiler_owee.Owee_elf.section -> unit
t ->
X86_proc.Section_name.t ->
?body:bytes ->
Compiler_owee.Owee_elf.section ->
unit

val current_offset : t -> int64

Expand Down
3 changes: 2 additions & 1 deletion backend/internal_assembler/symbol_table.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ val num_locals : t -> int

val make_undef_symbol : t -> string -> String_table.t -> unit

val make_section_symbol : t -> Compiler_owee.Owee_buf.u16 -> 'a -> Symbol_entry.t
val make_section_symbol :
t -> Compiler_owee.Owee_buf.u16 -> 'a -> Symbol_entry.t

val make_symbol :
t -> X86_binary_emitter.symbol -> Section_table.t -> String_table.t -> unit
Expand Down
2 changes: 2 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
(flags
(:standard -warn-error +A))))

(vendored_dirs ocaml)

; Since upstream has the middle end code inside ocamloptcomp, we do the
; same for the moment.

Expand Down
1 change: 1 addition & 0 deletions external/memtrace/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
;; the build, in a way that leads to less merge conflicts when
;; updating memtrace compared to deleting those directories in
;; the git subtree.

(dirs src)
1 change: 0 additions & 1 deletion external/memtrace/src/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(library
(name memtrace)
(libraries unix threads))

15 changes: 0 additions & 15 deletions middle_end/.ocamlformat

This file was deleted.

4 changes: 0 additions & 4 deletions middle_end/.ocamlformat-enable

This file was deleted.

13 changes: 0 additions & 13 deletions middle_end/flambda2/.ocamlformat

This file was deleted.

3 changes: 2 additions & 1 deletion middle_end/flambda2/algorithms/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_algorithms)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard -principal))
(ocamlopt_flags
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/bound_identifiers/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_bound_identifiers)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/cmx/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_cmx)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/compare/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_compare)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
(library
(name flambda2)
(wrapped false)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/from_lambda/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_from_lambda)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
3 changes: 2 additions & 1 deletion middle_end/flambda2/identifiers/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(library
(name flambda2_identifiers)
(wrapped true)
(instrumentation (backend bisect_ppx))
(instrumentation
(backend bisect_ppx))
(flags
(:standard
-principal
Expand Down
Loading