Commit Graph

60 Commits

Author SHA1 Message Date
Alex Richardson
231f58903b [make][clang] Do not add unsupported warning flags
Currently, clang does not support the -Wno-nonnull-compare and
-Wmaybe-uninitialized warning flags so this adds lots of unknown warning
flag output for each compile job when not using GCC.
This commit adds a makefile macro to check for supported warning flags
and only adds them if the compiler actually supports them.
2023-06-01 17:50:50 -07:00
Pedro Falcato
8ebbcea5ed [ubsan] Add UBSAN implementation
Add an UBSAN implementation and a new UBSAN switch to the make build.
The implementation is taken from Onyx and handles most of the cases
that should be needed for a kernel build. Floating point and fancy
C++ CFI features are not supported yet.

To build with UBSAN, pass UBSAN=1 to make such as:
PROJECT=pc-x86-64-test make -jN UBSAN=1
2023-02-18 16:47:16 -08:00
Travis Geiselbrecht
2367686854 [make] add a way for a module to opt into additional warnings
Move -Wmissing-declarations and -Wmissing-prototypes into this bucket.
Opt in most of the core top level modules in the system. More to follow.
2022-10-23 23:16:48 -07:00
Travis Geiselbrecht
3dff26ae7b [make] add BUILDDIR_SUFFIX build variable
This allows you to tag your build dirs with an optional string.

Update scripts/buildall to also allow building all release (DEBUG=0)
builds. Add a few other convenience switches.
2022-07-23 15:57:53 -07:00
Travis Geiselbrecht
cd96c43006 [make] define and undefine some make variables
Based on building with --warn-undefined-variables, find a few places in
the build system where undefined variables were used incorrectly, or
never set due to unused code.
2022-07-22 23:45:42 -07:00
Travis Geiselbrecht
6462cbf51c [arch][fpu] add ability to specify per file or module if code needs fpu
Have the arch define additional compiler flags to explicit support or
not support a floating point unit.

Add ability for modules to per file or for the whole module mark code
as needing floating point support.

Add default flags for arm64, riscv, and x86 toolchains.

Needed because gcc 12 is getting much more aggressive about using vector
instructions for non float code, so getting away with avoiding it was
no longer working.

Still not perfect: printf code is being compiled with float, so it's
possible to use floating point instructions inside core kernel or
interrupt handling code if a printf is used.

Possibly will have problems on architectures where mixing float and non
float code at the linker generates issues, but so far seems to be okay.
2022-07-17 16:32:24 -07:00
Travis Geiselbrecht
6edff96534 [make] update ip address to try to copy to in the 'install' target 2022-06-05 15:58:06 -07:00
Travis Geiselbrecht
1e88a6c354 [build] add commented out -Wmissing-declarations
This is a useful warning to have on, but keep it off for now since there
are a ton of warnings here, and probably in external projects that use
LK.

CLs incoming to fix the most egregious warning violations this uncovers.
2021-10-21 23:05:24 -07:00
Travis Geiselbrecht
ddd7cba04d [build] add a few pseudo targets to assist with building
list-arch and list-toolchain will compute and print the architecture and
toolchain needed to build the project the build is set to.

Used by the CI builder to decide what toolchain to grab.
2021-09-18 16:51:15 -07:00
Nick Bray
3f549a2e25 [make] Defer binding of EXTRA_BUILDDEPS to all::
Currently EXTRA_BUILDDEPS is evaluated before build.mk. This means that
userspace apps or other EXTRA_BUILDRULES cannot add items to
EXTRA_BUILDDEPS and have it function as would be expected.

Bug: 143636864
Change-Id: Idc1504b09f31b4c54148bb6892193d11f45e08ff
2021-04-08 23:55:27 -07:00
Travis Geiselbrecht
461ecbb677 [make][cpp] bump cpp revision to C++14
Shouldn't be a large problem, since it's been standard in gcc and clang
for quite a few years at this point.
2021-04-02 19:28:58 -07:00
Travis Geiselbrecht
7b0ca3c984 [make] print debug level on build 2021-02-14 20:08:35 -08:00
Travis Geiselbrecht
1272d037aa [dev][virtio] remove some extraneous __PACKED attributes
From working with -Wpacked its clear that some of the virtio
structures are overly packed and result in bad codegen on particular
architectures such as riscv. Roll back from using packed but
statically assert that the sizes are correct for some future arch
where things naturally pack differently.
2020-07-25 20:04:21 -07:00
Travis Geiselbrecht
ba530722f5 [warning] add -Wdouble-promotion
Mostly just a few warnings where things are promoted via passing floats to
printf. Those we should generally remove anyway because they're just
benchmarking code. Most things LK runs on either doesn't have float or
doesn't have double sized floats.
2020-07-25 17:16:22 -07:00
Travis Geiselbrecht
f7d8e2300c [warnings] add -Wshadow which helps detect local variables that override globals
Nothing particularly bad showed up but cleaned up a bit of code.
2020-07-25 16:49:25 -07:00
Travis Geiselbrecht
5690a8bb58 [arch] make sure the arch rules file sets TOOLCHAIN_PREFIX, make sure riscv picks up the alt selector
ARCH_riscv*_TOOLCHAIN_PREFIX should override TOOLCHAIN_PREFIX like it does on some other arches.
While was at it clean up the rules.mk file a bit.
2020-07-12 13:41:11 -07:00
Travis Geiselbrecht
7d9f80974d [make][flags] remove -finline, which apparently does nothing
Been carrying this flag around for years but from sleuthing around in
the compiler it seems to only exist as the opposite to -fno-inline which
has an actual effect. Only reason -finline would do anything would be to
cancel a previous -fno-inline switch.
2020-05-16 18:54:44 -07:00
Travis Geiselbrecht
a634b338c5 [make] tweak the way top level modules are included and add a few comments
No functional change.
2019-07-13 15:56:08 -07:00
Travis Geiselbrecht
08a4ee17f0 [make] add build switch to set -Werror in compile steps 2018-12-16 16:54:31 -08:00
Travis Geiselbrecht
5d43aa25eb [arch][rules] create ARCH_LDFLAGS and clean up all the arch rules files to consistently use ARCH_* vars 2018-11-30 22:00:45 -08:00
Travis Geiselbrecht
5dea3e1933 [warnings] fix a few warnings introduced with newer version of gcc
Most of the warnings are new, such as needing to mark fallthroughs on
cases explicitly. A few are based on signed vs unsigned comparisons.

Disable one warning that was annoying about comparing null to arguments
marked nonnull.
2018-03-15 14:10:12 -07:00
Travis Geiselbrecht
1332d188cb [make][compiler] add -fno-common
This removes the COMMON section merging logic, which actually uncovered
a few duplicately declared symbols across compilation units.
2016-11-17 14:44:21 -08:00
Girts
3972b18697 [make] [lib/version] remove a misplaced .PHONY (#170)
When lib/version was included, a rule depended on .PHONY.  This would
unexpectedly invoke other rules defined as dependent on .PHONY (standard
phony-ness signal).

As a side effect, this used to generate srcfiles.txt and
include_paths.txt in build dir. Since they are useful, we might always
build those anyway, and not make them phony at all.
2016-10-07 11:24:29 -07:00
Girts Folkmanis
9a2fcf2b60 [make] don't call build engine multiple times.
If some included rule.mk defines an additional make target that the user
might want to call (e.g., "flash"), and user specifies a project name on
the command line, then previously the outer "makefile" would call
engine.mk multiple times. The new logic prevents that.

Additionally, silence extra "Nothing to be done" messages when calling
engine.mk again after removing the project name from make goals.
2016-09-30 10:41:23 -07:00
Travis Geiselbrecht
c3165fcd2a [make] explicitly set the C and C++ standards to C11 and C++11
Seems to be supported at least back to gcc 4.8.2, which is I think
a reasonable minimum version.
2016-02-21 13:40:23 -08:00
Travis Geiselbrecht
6b480fd051 [make] remove -fno-builtin 2016-02-07 16:05:46 -08:00
Travis Geiselbrecht
84709d49f5 [make] add a quick in dirty help target for the build system
make help: a quick overview of how to use the build system
make list: a list of all the buildable projects
2016-01-30 14:43:12 -08:00
Travis Geiselbrecht
0bea90f76c [make] add the ARCH_* compile options to config.h 2015-12-08 14:20:37 -08:00
Travis Geiselbrecht
8a57db12ee [make] output a text file with all the source files and include paths used in the build 2015-11-20 21:00:44 -08:00
Travis Geiselbrecht
0e1ce411ba [make] add ability to set EXTRA_LINKER_SCRIPTS in modules
This allows for individual modules to extend the main linker script,
primarily to add their own sections to interate over.
Remove the main shared_* linker scripts.
2015-10-26 16:47:18 -07:00
Travis Geiselbrecht
3cb52cdf3d [make] add -Werror=return-type
Why gcc just warns about no return statement in a function that is supposed
to return something, I dunno. Fix that glitch.
2015-08-31 12:16:49 -07:00
Michael Ryleev
42694e06e6 [make] Fixup dependencies for modules included by EXTRA_BUILDRULES
Move statement that sets DEPS make variable a bit later in engine.mk
execution flow (after including make/build.mk) so that it would include
modules added through EXTRA_BUILDRULES mechanism.

Change-Id: I5c7a02eaf272f009a81ac9868f378b9baa23faae
2015-08-24 15:47:29 -07:00
Arve Hjønnevåg
2c9c5959e7 Merge branch 'master' of https://github.com/travisg/lk into smp
Change-Id: Iecb11d57b6f089234c0826932bdb229588939750
2015-05-18 16:49:37 -07:00
Travis Geiselbrecht
9fcf5cffaa [make] add -Wno-unused-label to the global compile flags
This is almost always due to #ifdefed code referring to a label.
Since you cant mark a label as UNUSED the way you can a variable,
adding this warning squelch seems like the best strategy.
2015-05-02 22:48:57 -07:00
Michael Ryleev
21a5fd3322 [make] Add support for ARCH_XXX flags
Added architecture specific variables

    ARCH_COMPILEFLAGS
    ARCH_CFLAGS
    ARCH_CPPFLAGS
    ARCH_ASMFLAGS

These variables are passed directly to $(CC) command and
are supposed to have global but architecture specific
settings.

Change-Id: I0929afacb4ad5229f503217ee370e0a84a15f35d
2015-03-19 18:01:10 -07:00
Michael Ryleev
6d352765a1 [make] Add support for EXTRA_BUILDRULES
All makefiles added to EXTRA_BUILDRULES variable
will be included right before processing bulk of build.mk

Change-Id: Ic37e37ea7469ee57e6f6543f378c5d0c1510824b
2015-03-19 18:01:10 -07:00
Michael Ryleev
fba0af578c [make] Cleanup overlay processing order
Add LKROOT to LKINC only if it is not already there.
This would allow to specify particular overlay processing
order if required.

Remove adding separate LKROOT/include to GLOBAL_DEFINES as
It is already a part of LKINC list.

Add all directories specified by LKINC to GLOBAL_LDFLAGS instead
of just LKROOT

Change-Id: Ia61623f88f2c5978182c40b09d98b6e5b84e3955
2015-03-19 18:01:10 -07:00
Michael Ryleev
c22b2f4576 [make] Add STRIP tool
Change-Id: I4ff5c33d4f84b3fcd52cb6ec9953595e68721205
Signed-off-by: Michael Ryleev <gmar@google.com>
2015-03-19 18:01:10 -07:00
Arve Hjønnevåg
cda47f1f9d [make] Remove .hex file from all target
This fileformat does not support large offsets, and fail to build if
the kernel base is at a high address on 64 bit systems.

Change-Id: I4e2cb58f46c62fded0de485c982dfdc5b6f3622f
2015-03-08 19:05:12 -07:00
Travis Geiselbrecht
12ff899fb6 [make] add -Wwrite-strings to the global warning flags 2015-03-03 14:29:31 -08:00
Travis Geiselbrecht
7158df8fdb [make] try to enable colorized gcc error output, if supported 2015-01-29 20:38:24 -08:00
Travis Geiselbrecht
17b1d8772c [arch][arm] turn on linker GC for big arm by default 2014-10-23 13:22:34 -07:00
Travis Geiselbrecht
489a3c561d [make] fix the quoting around make spotless rm 2014-08-25 15:26:48 -07:00
Travis Geiselbrecht
896e273385 [make] properly prefix the spotless path with BUILDROOT
Change-Id: I3cbda4c95751124252bc535a82a78bc6a6c7f8f5
2014-08-22 14:59:17 -07:00
Travis Geiselbrecht
0780dc8782 [make] allow passing a default project to build if none specified and set the build output root
Change-Id: I5241108517be250535329513996c844f68073564
2014-08-08 16:27:11 -07:00
Travis Geiselbrecht
f21ad5d749 [make] miscellaneous make system tweaks
-Have arch set the default optimization level. Most will use
 O2, but arm-m sets to Os.
-Make the link time garbage collection be optional. Only set
 for arm-m.
2014-03-22 21:03:03 -07:00
Travis Geiselbrecht
e36bb92d7d [make] also generate lk.elf.sym.sorted 2014-01-26 22:51:51 -08:00
Dima Zavin
e2c9b83a3a [arch] add -L $(LKROOT) to GLOBAL_LDFLAGS to let ld find common scripts
Change-Id: I497a8ef9c2b13b3b179db05986e7463688a21e5b
Signed-off-by: Dima Zavin <dima@android.com>
2013-08-05 09:43:25 -07:00
Travis Geiselbrecht
e14309a95b [make] add GLOBAL_SRCDEPS variable
Build a phony rule that depends on a delay evaluated SRCDEPS
variable at the end of the build so that modules that add to
it are properly tracked.
2013-07-31 12:13:11 -07:00
Travis Geiselbrecht
7e8b333b97 [make] add new TESTANDREPLACEFILE macro
Split the MAKECONFIGHEADER macro into the part that generates
the header and the part that tests if you should replace the
target file with the generated one.
2013-07-31 12:12:07 -07:00