Commit Graph

54 Commits

Author SHA1 Message Date
Pawel Jakub Dawidek
a6c0f1f242 To be able to use printf extensions we need to turn off gcc format checking.
Following the convention of NO_WERROR and NO_WCAST_ALIGN add NO_WFORMAT,
which, when defined in Makefile, turns off compile-time format checking
(by adding -Wno-format), but still allows to use high WARNS level.

MFC after:	2 weeks
2011-03-07 09:28:21 +00:00
Warner Losh
25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Rui Paulo
187278cadc For every instance of '.if ${CC} == "foo"' or '.if ${CC} != "foo"' in
Makefiles or *.mk files, use ${CC:T:Mfoo} instead, so only the basename
of the compiler command (excluding any arguments) is considered.

This allows you to use, for example, CC="/nondefault/path/clang -xxx",
and still have the various tests in bsd.*.mk identify your compiler as
clang correctly.

ICC if cases were also changed.

Submitted by:	Dimitry Andric <dimitry at andric.com>
2010-08-17 20:39:28 +00:00
Marcel Moolenaar
c9a900ed44 Allow suppression of -Wcast-align for WARNS>=4 by defining
NO_WCAST_ALIGN. The headers of the standard C++ library are
not 64-bit clean and trigger the warning. This prevents use
of WARNS>=4 on ia64 for example.
2010-02-18 02:06:57 +00:00
Edward Tomasz Napierala
e73a17cf23 Undo r169961, removing WITH_GCC3, added as a temporary workaround three
years ago.
2010-01-18 21:56:08 +00:00
Ed Schouten
03bc68ca09 Disable K&R style function definitions for WARNS=6.
Unfortunately there are two slight problems with that:

- Yacc and lex might generate code that generates warnings because of
  this. Require yacc and lex to be rebuilt during bootstrap. I'm not
  incrementing __FreeBSD_version here, because I assume someone else
  will do this eventually.

- When running `make buildkernel', it uses share/mk from the source
  treeo to build aicasm. Because aicasm also depends on lex, this would
  break. Lower WARNS to 5 for now. We should just increment it to 6
  again somewhere in the very far future.
2009-12-31 00:07:26 +00:00
Ruslan Ermilov
b48db8e12d Unbreak NO_WARNS, keeping CSTD effect on CFLAGS out of its control.
Unbreak compiles with icc.
2009-10-22 11:45:35 +00:00
Roman Divacky
9448b439ec Set CSTD in all cases except when CC=icc and NO_WARNS is set. This
way we can set desired C standard even for cross tools etc.

Tested by:	make universe
Approved by:	ed (maintainer)
OK by:		das
2009-10-21 17:07:46 +00:00
Roman Divacky
300d03a832 Switch over to gnu99 compilation on default for userland.
Tested by:	make universe
Tested by:	ports exp build (done by pav)
Reviewed by:	ru
Reviewed by:	silence on arch
Approved by:	ed (mentor)
2009-03-14 17:55:16 +00:00
Warner Losh
a678ba4ec8 Turn of SSP for mips for now until support is added to the base
architecture.
2008-07-23 06:14:21 +00:00
Olivier Houchard
ad8abd6c4d Disable SSP on arm for the time being.
The segfaults when using SSP seem to be a gcc bug, a patch is available
in the gcc bugzilla, and will be imported once it's committed
into the official gcc tree.
2008-07-19 00:19:16 +00:00
Ruslan Ermilov
042df2e2da Enable GCC stack protection (aka Propolice) for userland:
- It is opt-out for now so as to give it maximum testing, but it may be
  turned opt-in for stable branches depending on the consensus.  You
  can turn it off with WITHOUT_SSP.
- WITHOUT_SSP was previously used to disable the build of GNU libssp.
  It is harmless to steal the knob as SSP symbols have been provided
  by libc for a long time, GNU libssp should not have been much used.
- SSP is disabled in a few corners such as system bootstrap programs
  (sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves.
- It should be safe to use -fstack-protector-all to build world, however
  libc will be automatically downgraded to -fstack-protector because it
  breaks rtld otherwise.
- This option is unavailable on ia64.

Enable GCC stack protection (aka Propolice) for kernel:
- It is opt-out for now so as to give it maximum testing.
- Do not compile your kernel with -fstack-protector-all, it won't work.

Submitted by:	Jeremie Le Hen <jeremie@le-hen.org>
2008-06-25 21:33:28 +00:00
John Birrell
cfb5b3256b Re-enable -Werror again.
This time, change the default CFLAGS to match the simple defaults that
the tinderboxes use. That is, don't use -fno-strict-aliasing by default.

My last attempt to re-anable -Werror gave me a lesson in what strict
aliasing is all about. There was code in libthr that wasn't 64-bit clean.
The default use of -fno-strict-aliasing hid that.

By using -fno-strict-aliasing by default we were choosing to ignore
problems in code which had the potential to shoot ourselves in the
foot. Sometimes it would be the 64-bit foot. I have both feet. The left
ones are 32 bits and the right ones are 64 bits. Don't ask about my
endian orientation. :-)

The -fno-strict-aliasing compiler arg can still be used if NO_STRING_ALIASING
is define in make.

We are early in the FreeBSD 8 development, so we have the opportunity to
wait and see if this works for us. I am sure that people will complain.
We can easily revert this. All I ask is that we take sides: clean code or
not. YMMV.

Note that by using -fno-strict-aliasing the build won't actually break.
Only where WARNS is set (and -Werror is used) will a compiler warning break
the build. The use of WARNS levels implies (to me at least) that the
developer has taken some care to make the code pass basic checks. This
commit makes those checks just a little bit more strict.
2007-11-22 23:21:12 +00:00
John Birrell
f9f50330f3 Unfortunately the tinderbox setup uses custom CFLAGS which are a big
obstacle to enabling -Werror. I'll continue to work on cleaning up the
code so that we can keep this enabled.

If the tinderboxes would just use the default CFLAGS set in this file,
all would be fine and we'd be able to make use of -Werror.
2007-11-19 22:39:39 +00:00
John Birrell
76f9e2ec8f Re-enable -Werror ins WARNS as it was roughly 6 months ago before
being disabled while gcc 4.2 was bedded in.

Tested with 'make release' (amd64 arm i386 ia64 pc98 powerpc sparc64 sun4v)
2007-11-19 09:09:02 +00:00
David E. O'Brien
9eef6e338b Temporarily add 'WITH_GCC3' that removes -Wno-pointer-sign from the
compiler invocation.  This is just to help get over the hump of people
tracking down bugs that may cross the GCC 4.2 upgrade.
It is envisioned that this option goes away after a suitable amount
of time.
2007-05-24 21:53:42 +00:00
Alexander Kabaev
d9e2d1a3b5 Universally disable -Werror until src/ is in better shape for GCC 4.2.
There are new warnings that kill the build otherwise.

Disable pointer destination sign mismatch warning alltogether. Our tree
is in no shape to have that enabled yet.
2007-05-19 04:41:05 +00:00
John Birrell
f4c93e2c4a Allow a makefile to set IGNORE_PRAGMA so that OpenSolaris code can
be built with other gcc warnings enabled.

Every Solaris source file has a #pragma ident in it. We can just
ignore those definitions.
2006-11-04 04:39:05 +00:00
Dag-Erling Smørgrav
513f04ca55 Reintroduce CSTD, which allows a Makefile to specify the precise dialect
of C in which the program or library is written.

Note that this is *not* intended to be used across the whole tree.  It
is intended to be used for individual libraries or programs which use
specific language features which the compiler must know about in order
to produce correct warnings at high WARNS levels.

MFC after:	1 month
2006-08-11 17:28:59 +00:00
David E. O'Brien
8d918dbd49 Move -Wunused-parameter from WARNS level 3 level 4.
Also break long lines -- note that the '\' must be up against the last
character of a line to keep command-line spacing proper.

Requested by:	rwatson
2005-01-16 21:18:16 +00:00
David E. O'Brien
626cba20c7 Use >= so we can use the actual WARNS levels. 2005-01-16 21:08:31 +00:00
Tom Rhodes
06d6e4fcfe This are the build infrastructure changes to allow to use the
Intel C/C++ compiler (lang/icc) to build the kernel.

The icc CPUTYPE CFLAGS use icc v7 syntax, icc v8 moans about them, but
doesn't abort. They also produce CPU specific code (new instructions
of the CPU, not only CPU specific scheduling), so if you get coredumps
with signal 4 (SIGILL, illegal instruction) you've used the wrong
CPUTYPE.

Incarnations of this patch survive gcc compiles and my make universe.
I use it on my desktop.

To use it update share/mk, add
	/usr/local/intel/compiler70/ia32/bin	(icc v7, works)
or
	/usr/local/intel_cc_80/bin		(icc v8, doesn't work)
to your PATH, make sure you have a new kernel compile directory
(e.g. MYKERNEL_icc) and run
	CFLAGS="-O2 -ip" CC=icc make depend
	CFLAGS="-O2 -ip" CC=icc make
in it.

Don't compile with -ipo, the build infrastructure uses ld directly to
link the kernel and the modules, but -ipo needs the link step to be
performed with Intel's linker.

Problems with icc v8:
 - panic: npx0 cannot be emulated on an SMP system
 - UP: first start of /bin/sh results in a FP exception

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by:	silence on -arch
Submitted by:	netchild
2004-03-12 21:36:12 +00:00
Dag-Erling Smørgrav
5193980ced Remove -Wbad-function-cast. Its main purpose is to catch bugs that we
already catch with -Wstrict-prototypes, and it causes spurious warnings
for some perfectly legitimate constructs.
2004-02-16 20:07:06 +00:00
Ruslan Ermilov
804517817f Put the warning flags to where they belong (into CWARNFLAGS).
This allows us to easily override them when necessary, e.g.,
to selectively disable warnings in libc/ contributed sources.
2004-01-11 10:29:55 +00:00
Warner Losh
139c58b300 Put on the core hat and back out all of the CSTD= changes. Core will
deal with working with the parties to define a coherent definition for
CSTD that doesn't break things.

Core hat seconded by: markm
2003-06-14 17:41:59 +00:00
Dag-Erling Smørgrav
b6723d4dfb Revert to a known-good state. Anyone desiring to experiment with stricter
global settings is free to do so in his or her own source tree.
2003-06-14 11:57:44 +00:00
Peter Wemm
333c9db6d0 We cannot use c99 on amd64 either due to lack of alloca(). libc:strptime()
uses alloca() and alloca is impossible to implement as a callable function
on amd64.  It has to be a compiler builtin.  Note that the bigger problem
is that libc is not c99 clean internally.
2003-06-13 21:54:21 +00:00
David E. O'Brien
10f7bcc5a8 Be C std strict on i386 and amd64 as we can. Be loose on Alpha and ia64. 2003-06-07 08:05:35 +00:00
David E. O'Brien
b307c7420c Compile our code as C99 w/GNU extensions by default.
We can't use straight "c99" due to the lack of alloca.S for non-i386 platforms.
2003-06-06 16:55:05 +00:00
David E. O'Brien
b9c19cc240 I got a bazzar bug report 2003-06-02 08:10:57 +00:00
David E. O'Brien
1cd2abf7af Turn back on c99, the tree should be ready for it now. 2003-06-02 06:26:14 +00:00
David E. O'Brien
479b54330b To quote Tony Maher <tonymaher@optushome.com.au>, "maybe 3rd time lucky ;-)"
*sigh* Just can't get a brake when trying to react too quickly and fix the build.
2003-06-02 01:01:42 +00:00
David E. O'Brien
f14fd87c5e Temperarly turn off building the tree with c99.
I swore this made it thru a 'make world', but I don't know what happened.
2003-06-02 00:11:07 +00:00
David E. O'Brien
28c3f28e32 Use a bigger hammer -- keep all -std= out of CXXFLAGS.
Also allow for "CSTD=" in a Makefile.
2003-06-01 22:13:45 +00:00
David E. O'Brien
5622a7e02d Do not set a C standard for the C++ compiler. 2003-06-01 21:33:05 +00:00
David E. O'Brien
5890829965 Compile our code as C99 by default. 2003-06-01 18:31:25 +00:00
David E. O'Brien
cf459fc35c CSTD is virtually worthless for WARNS=2-5. Return -pedantic to WARNS=6+. 2003-05-31 16:37:22 +00:00
David E. O'Brien
239e385f11 Make CSTD style match the rest of file. 2003-05-31 16:30:39 +00:00
Dag-Erling Smørgrav
a3f59e65f1 Whitespace cleanup (1.15 had spaces instead of tabs) 2003-05-05 21:14:36 +00:00
Dag-Erling Smørgrav
9820f41cd3 Don't use -pedantic unless we also set -std of some kind. 2003-05-05 21:13:32 +00:00
Dag-Erling Smørgrav
77695b344b Add a mechanism to allow Makefiles to specify the particular C dialect
in which the source code is written.  This is controlled by the CSTD
variable, which can have one of the following values:

  - "k&r"		=> -traditional
  - "c89" or "c90"	=> -std=iso9899:1990
  - "c94" or "c95"	=> -std=iso9899:199409
  - "c99"		=> -std=iso9899:1999

The corresponding option is added to CFLAGS regardless of WARNS level.
This also removes -ansi from WARNS level 6, but adds -Wno-long-long to
work around a weird gcc bug (-ansi, which is supposedly equivalent to
-std=iso9899:1990, seems to turn long long warnings off instead of on)

If CSTD is undefined, CFLAGS are unchanged except for the -ansi /
-Wno-long-long change mentioned above for WARNS level 6.
2003-05-01 14:36:27 +00:00
Warner Losh
30aaff1192 Migrate to a new way of dealing with building from old revisions of
FreeBSD.  This method attempts to centralize all the necessary hacks
or work arounds in one of two places in the tree (src/Makefile.inc1
and src/tools/build).  We build a small compatibility library
(libbuild.a) as well as selectively installing necessary include
files.  We then include this directory when building host binaries.

This removes all the past release compatibilty hacks from various
places in the tree.  We still build on tip of stable and current.  I
will work with those that want to support more, although I anticipate
it will just work.

Many thanks to ru@, obrien@ and jhb@ for providing valuable input at
various stage of implementation, as well as for working together to
positively effect a change for the better.
2003-04-05 20:30:30 +00:00
Ruslan Ermilov
0e80a2f601 -Wall implies -Wuninitialized if -O is also in effect.
-Wuninitialized does not work without -O.

This fixes the ${WARNS} > 4 compilations with -O0.

Spotted by:	marcel
2003-04-04 10:47:06 +00:00
Ruslan Ermilov
effd19ed24 Enable cpp(1) warnings in system headers. GCC is oriented on
glibc which is externally maintained, so GCC ships with these
warnings turned off by default.  This is also consistent with
the src/contrib/gcc/c-lex.c,v 1.2 change.
2003-03-31 13:10:51 +00:00
Ruslan Ermilov
40c6b893d8 Take __FreeBSD_version into account when BOOTSTRAPPING. 2002-11-13 13:49:29 +00:00
David E. O'Brien
bf4ca1009b Be more strict with WARNS now -- the GCC 3.1 turmoil is behind us. 2002-07-07 18:47:52 +00:00
David E. O'Brien
be5181d5b1 Tweak the WARNS levels a tad. 2002-05-19 18:24:00 +00:00
David E. O'Brien
b0b7c2164c Gcc 3.1 has different -Wx flags. 2002-05-10 01:58:16 +00:00
David E. O'Brien
89d1cbc7aa Add WARNS levels 5 and 6:
5 gives us -Wuninitialized rather than -Wno-uninitialized
6 gives us full BDECFLAGS
2002-04-10 02:45:22 +00:00
Ruslan Ermilov
7cf143f761 FreeBSD prior to 4.5-RELEASE and older versions of 5.0-CURRENT do not
have the __FBSDID() macro in <sys/cdefs.h>.  Fix this once and for all
for tools that need to be bootstrapped.

PR:		bin/36747
MFC after:	3 days
Prodded by:	obrien
2002-04-07 17:03:06 +00:00