Skip to content

Various build-system fixes and enhancements#12108

Merged
shindere merged 9 commits intoocaml:trunkfrom
shindere:native-cc-cflags
Mar 18, 2023
Merged

Various build-system fixes and enhancements#12108
shindere merged 9 commits intoocaml:trunkfrom
shindere:native-cc-cflags

Conversation

@shindere
Copy link
Copy Markdown
Contributor

The original purpose of this PR was to provide a configurable build variable
to provde C-compiler flags to be used specifically when compiling C object files for
linking with native code.

This is going to be useful for TSan, the threadsanitizer, but has been
designed to be general and suableby other features.

Finally this PR consists in a series of commits that enhance and fix the
build system in various ways.

It's best reviewed commit by commit and the individual commit messages
hopefully explain each change.

Also, each commit is conciseandshould be rather self-explanatory and easy to
review.

This commit contains two changes to the root Makefile:

1. Removal of the following line:

$(DEPDIR)/runtime/%.bpic.$(D): OC_CFLAGS += $(SHAREDLIB_CFLAGS)

This line is useless because it makes no sense to alter any variable
in the CFLAGS category for the computation of dependencies, since only
the C preprocessor is involved in this stage and it does not take
C flags into account anyway, only C preprocessor flags.

2. When computing the dependencies for $(DEPDIR)/runtime/%.npic.$(D),
one should not refer to $(SHAREDLIB_CFLAGS), for a similar reason.

It has been verified that SHAREDLIB_CFLAGS is either empty, or contains
just -fPIC which is indeed not necessary for computing dependencies
(it is indeed a C flag rather than a C preprocessor flag).
In this target-specific definition, C and C preprocessor flags were mixed.
This commit distinguishes one form the other.
Given the convention that the OC_* build varialbes are reserved for
the build system, it seems better to make sure all of them are defined
in the private Makefile.build_config file, rather than in Makefile.config
which gets installed and thus becomes public.

This commit moves the definitions of OC_CFLAGS, OC_CPPFLAGS,
OC_LDFLAGS, OC_DLL_LDFLAGS and OC_EXE_LDFLAGS from Makefile.config.in to
Makefile.build_config.in. It also moves the defintion of MKEXE_VIA_CC,
since this variable relies on private build varables and does not seem
relevant or useful outside of the context of the build of the compiler itself.
The renamings done in this commit are:

OC_COMMON_CFLAGS -> OC_COMMON_COMPFLAGS
OC_COMMON_LDFLAGS -> OC_COMMON_LINKFLAGS
OC_BYTECODE_LDFLAGS -> OC_BYTECODE_LINKFLAGS
OC_NATIVE_CFLAGS -> OC_NATIVE_COMPFLAGS
OC_NATIVE_LDFLAGS -> OC_NATIVE_LINKFLAGS
This means moving its definition from Makefile.common to
Makefile.build_config.in
This is to let configure specify flags that will be used when
compiling C files to be linked with native code.

The variable is not used in the build system yet, just defined.
When compiled for linking with native code, C files use both the
common preprocessor flags and the native-specific cppflags.

The same should happen for assembly files and this commit makes sure
this is the case.
Copy link
Copy Markdown
Contributor

@MisterDA MisterDA left a comment

Choose a reason for hiding this comment

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

We've reviewed the PR offline, and all the changes make sense to me. Thanks Sébastien!

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Mar 17, 2023 via email

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM (took a quick look at the PR; also approving based on @MisterDA's review)

@shindere shindere merged commit 3cac946 into ocaml:trunk Mar 18, 2023
@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Mar 18, 2023 via email

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