kernel build error with optimization levels other than -O2

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

kernel build error with optimization levels other than -O2

Colton Lewis
Building the -current source tree with COPTS='-O1'
or anything lower than -O2 results in a linker error for several functions.

_cd sys/arch/amd64/compile/GENERIC.MP/_
_make obj COPTS='-O1'_
_make config COPTS='-O1'_
_make build COPTS='-O1'_

The problem seems to come from clang using slightly different inline semantics
from gcc. [1] This build error can be fixed with a small patch
declaring some inline
functions static.

[1] http://llvm.1065342.n5.nabble.com/Problem-with-inline-keyword-td47047.html

Sincerely,
Colton Lewis

make.error (2K) Download Attachment
static-inline.patch (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: kernel build error with optimization levels other than -O2

Philip Guenther
On Sat, 27 Oct 2018, Colton Lewis wrote:
> Building the -current source tree with COPTS='-O1' or anything lower
> than -O2 results in a linker error for several functions.

In general, we do not endevour to support compilation with different
optimization levels or flags.  The developers don't do it (because we
don't see a benefit to running such a kernel), so issues like this will
crop up.


In this case, since the issue is a standards compliance issue, I'm mildly
inclined towards thinking we should fix it.  For the trivial functions,
marking them static seems fine; uhci_find_prev_qh() should perhaps just
drop the 'inline': the compiler can still inline it.


> The problem seems to come from clang using slightly different inline
> semantics from gcc. [1] This build error can be fixed with a small patch
> declaring some inline functions static.

'static' should always be placed first in the declaration.  C11 declared
"placement of a storage-class specifier other than at the beginning of the
declaration specifiers in a declaration" to be an obsolescent feature.


Philip Guenther

Reply | Threaded
Open this post in threaded view
|

Re: kernel build error with optimization levels other than -O2

Colton Lewis
On Sun, Oct 28, 2018 at 10:46 PM Philip Guenther
<[hidden email]> wrote:
> In this case, since the issue is a standards compliance issue, I'm mildly
> inclined towards thinking we should fix it.  For the trivial functions,
> marking them static seems fine; uhci_find_prev_qh() should perhaps just
> drop the 'inline': the compiler can still inline it.

I was aware of the policy, but judged I should still report it for the reason
you described. Also, It seemed like a dumb thing to break the build and
the fix was very simple.

> 'static' should always be placed first in the declaration.  C11 declared
> "placement of a storage-class specifier other than at the beginning of the
> declaration specifiers in a declaration" to be an obsolescent feature.

I trust the OpenBSD developers are more versed in the relevant
standards than me and will leave it to them to edit the fix as needed
unless told otherwise.

Thanks for the great work everyone.