Commit Graph

20311 Commits

Author SHA1 Message Date
Enji Cooper
0eb97cca9f Allow users to override CSTD/CXXSTD on a per-prog basis
The current logic for CSTD/CXXSTD requires homogenity as far as the
supported C/C++ standards, which is a sensible default. However, when
dealing with differing versions of C++, some code may compile with C++11, but
not C++17 (for instance). So in order to avoid having people convert over their
code to the new standard, give the users the ability to specify the standard on
a per-program basis.

This will allow a user to override the supporting standard for a set of
programs, mixing C++11 with C++14 (for instance).

Reviewed by:	asomers
Apprved by:	emaste (mentor)
MFC after:	1 month
MFC with:	r345708
Differential Revision: https://reviews.freebsd.org/D19738
2019-03-29 18:49:08 +00:00
Enji Cooper
e8067928ff Standardize -std=c++* as CXXSTD`
CXXSTD was added as the C++ analogue to CSTD.

CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.

This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.

As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.

Notes:

This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.

Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:

Before this commit:
```
CXXFLAGS+=	-std=c++14
```

After this commit:
```
CXXSTD=	c++14
```

Reviewed by:	asomers
Approved by:	emaste (mentor)
MFC after:	1 month
MFC with:	r345203, r345704, r345705
Relnotes:	yes
Tested with:	make tinderbox
Differential Revision:	https://reviews.freebsd.org/D19732
2019-03-29 18:45:27 +00:00
Enji Cooper
bdbf3440ce Revert r345706: the third time will be the charm
When a review is closed via Phabricator it updates the patch attached to the
review. I downloaded the raw patch from Phabricator, applied it, and repeated
my mistake from r345704 by accident mixing content from D19732 and D19738.

For my own personal sanity, I will try not to mix reviews like this in the
future.

MFC after:	1 month
MFC with:	r345706
Approved by:	emaste (mentor, implicit)
2019-03-29 18:43:46 +00:00
Enji Cooper
760b1a815b Standardize -std=c++* as CXXSTD`
CXXSTD was added as the C++ analogue to CSTD.

CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.

This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.

As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.

Notes:

This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.

Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:

Before this commit:
```
CXXFLAGS+=	-std=c++14
```

After this commit:
```
CXXSTD=	c++14
```

Reviewed by:	asomers
Approved by:	emaste (mentor)
MFC after:	1 month
MFC with:	r345203, r345704, r345705
Relnotes:	yes
Tested with:	make tinderbox
Differential Revision:	https://reviews.freebsd.org/D19732
2019-03-29 18:31:48 +00:00
Enji Cooper
752cabaa1c Revert r345704
I accidentally committed code from two reviews. I will reintroduce the code to
bsd.progs.mk as part of a separate commit from r345704.

Approved by:	emaste (mentor, implicit)
MFC after:	2 months
MFC with:	r345704
2019-03-29 18:16:33 +00:00
Enji Cooper
9a41926bfb CXXSTD is the C++ analogue to CSTD.
CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`,
otherwise for older versions of g++.

This change standardizes the CXXSTD variable, originally added to
googletest.test.inc.mk as part of r345203.

As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`.

Notes:

This value is not sanity checked in bsd.sys.mk, however, given the two
most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is
likely to work with both toolchains. This method will be refined in the future
to support more variants of C++, as not all versions of clang++ and g++ (for
instance) support C++14, C++17, etc.

Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD.
Example:

Before this commit:
```
CXXFLAGS+=	-std=c++14
```

After this commit:
```
CXXSTD=	c++14
```

Reviewed by:	asomers
Approved by:	emaste (mentor)
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D19732
2019-03-29 18:13:44 +00:00
Konstantin Belousov
5d00c5a657 Fix initial exec TLS mode for dynamically loaded shared objects.
If dso uses initial exec TLS mode, rtld tries to allocate TLS in
static space. If there is no space left, the dlopen(3) fails. If space
if allocated, initial content from PT_TLS segment is distributed to
all threads' pcbs, which was missed and caused un-initialized TLS
segment for such dso after dlopen(3).

The mode is auto-detected either due to the relocation used, or if the
DF_STATIC_TLS dynamic flag is set.  In the later case, the TLS segment
is tried to allocate earlier, which increases chance of the dlopen(3)
to succeed.  LLD was recently fixed to properly emit the flag, ld.bdf
did it always.

Initial test by:	dumbbell
Tested by:	emaste (amd64), ian (arm)
Tested by:	Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D19072
2019-03-29 17:52:57 +00:00
Bruce Evans
a32dbad556 Fix restoring to graphics modes in VGLEnd().
Correct restoring was only attempted for mode 258 (800x600x4 P).  (This
was the only useful graphics mode supported in the kernel until 10-15
years ago, and is still the only one explicitly documented in the man
page).  The comment says that it is the geometry (subscreen size) that
is restored, but it seems to only be necessary to restore the font
size, with the geometry only needed since it is set by the same ioctl.
The font size was not restored for this mode, but was forced to 16.

For other graphics modes, the font size was clobbered to 0.  This
confuses but doesn't crash the kernel (font size 0 gives null text).
This confuses and crashes vidcontrol.  The only way to recover was to
use vidcontrol to set the mode to any text mode on the way back to the
original graphics mode.

vidcontrol gets this wrong in the opposite way when backing out of
changes after an error.  It restores the font size correctly, but
forces the geometry to the full screen size.
2019-03-29 16:30:19 +00:00
Bruce Evans
cfcc114dcb Fix endless loops for handling SIGBUS and SIGSEGV.
r80270 has the usual wrong fix for unsafe signal handling -- just set
a flag and return to let an event loop check the flag and do safe
handling.  This never works for signals like SIGBUS and SIGSEGV that
repeat and works poorly for others unless the application has an event
loop designed to support this.

For these signals, clean up unsafely as before, except for arranging that
nested signals are fatal and forcing a nested signal if the cleanup doesn't
cause one.
2019-03-29 15:57:08 +00:00
Bruce Evans
0410dc5f5d Fix races in mouse signal handling almost properly using the INTOFF/INTON
method as in /bin/sh.

We still do technically undefined things in the signal handler, but it
is safe in practice to access state that is protected by INTOFF/INTON.

In a recent commit, I sprinkled VGLMouseFrozen++/-- operations in
places that need INTOFF/INTON.  This prevented clobbering of pixels
under the mouse, but left mouse signals deferred for too long.  It is
necessary to call the signal handler when the count goes to 0.  Old
versions did this in the unfreeze function, but didn't block actual
signals, so the signal handler raced itself.  The sprinkled operations
reduced the races, but when then worked to block a race they left
signals deferred for too long.

Use INTOFF/INTON to fix complete loss of mouse signals while reading
the mouse status.  Clobbering of the state was prevented by SIG_IGN'ing
mouse signals, but that has a high overhead and broke more than it
fixed by losing mouse signals completely.  sigprocmask() works to block
signals without losing them completely, but its overhead is also too
high.

libvgl's mouse signal handling is often worse than none.  Applications
can't block waiting for a mouse or keyboard or other event, but have
to busy-wait.  The SIG_IGN's lost about half of all mouse events while
busy-waiting for mouse events.
2019-03-29 15:20:48 +00:00
Bruce Evans
5ee94e9954 Fix VGLLine() in depths > 8.
It started truncating its color arg to 8 bits using plot() in r229415.
The version in r229415 is also more than 3 times slower in segmented
modes, by doing more syscalls to move the window.
2019-03-28 14:21:22 +00:00
Bruce Evans
baca0ce6b3 Fix VGLGetXY(), VGLSetXY() and VGLClear() for MEMBUFs in depths > 8.
This depends on PixelBytes being properly initialized, which it is for
all bitmaps constructed by libvgl except mouse cursor bitmaps.
2019-03-28 12:28:29 +00:00
Bruce Evans
fa68d9b94e Oops, r345496 got the pointer args backwards for bcopy() in VGLClear for
segmented modes.

Also fix some style bugs in the 2 changed lines.  libvgl uses a very non-KNF
style with 2-column indentation with no tabs except for regressions.
2019-03-28 09:51:37 +00:00
Ed Maste
09b47fc1c2 revert r341429 "disable BIND_NOW in libc, libthr, and rtld"
r345620 by kib@ fixed the rtld issue that caused a crash at startup
during resolution of libc's ifuncs with BIND_NOW.

PR:		233333
Sponsored by:	The FreeBSD Foundation
2019-03-28 02:12:32 +00:00
Mark Johnston
a273e09cb2 Fix pidfile_open(3) to handle relative paths with multiple components.
r322369's use of basename(3) was incorrect and worked by accident so
long as the pidfile path was absolute or consisted of a single
component.  Fix the basename() usage and add a regression test.

Reported by:	0mp
Reviewed by:	cem
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D19728
2019-03-27 19:40:18 +00:00
Bruce Evans
014ddcbce4 Fix accessing pixels under the mouse cursor:
Reading of single pixels didn't look under the cursor.

Copying of 1x1 bitmaps didn't look under the cursor for either reading
or writing.

Copying of larger bitmaps looked under the cursor for at most the
destination.

Copying of larger bitmaps looked under a garbage cursor (for the Display
bitmap) when the destination is a MEMBUF.  The results are not used, so
this only wasted time and flickered the cursor.

Writing of single pixels looked under a garbage cursor for MEMBUF
destinations, as above except this clobbered the current cursor and
didn't update the MEMBUF.  Writing of single pixels is not implemented
yet in depths > 8.  Otherwise, writing of single pixels worked.  It was
the only working case for accessing pixels under the cursor.

Clearing of MEMBUFs wasted time freezing the cursor in the Display bitmap.

The fixes abuse the top bits in the color arg to the cursor freezing
function to control the function.  Also clear the top 8 bits so that
applications can't clobber the control bits or create 256 aliases for
every 24-bit pixel value in depth 32.

Races fixed:

Showing and hiding the cursor only tried to avoid races with the mouse
event signal handler for internal operations.  There are still many
shorter races from not using volatile or sig_atomic_t for the variable
to control this.  This variable also controls freezes, and has more
complicated states than before.

The internal operation of unfreezing the cursor opened a race window
by unsetting the signal/freeze variable before showing the cursor.
2019-03-27 18:03:34 +00:00
Bruce Evans
aa1ce985e4 Fix copying of bitmaps in depths > 8. This fix is complete, except different
depths for the source and target are not supported.  The bits for higher
numbered planes (mostly for red) were either not copied or were copied to
lower numbered planes for nearby pixels.

Quick fix for creation of mouse cursor bitmaps in all depths.   This fix is
only complete for the default lightwhite cursor with a black frame.

Even the lightwhite and black colors are hard to find.  The templates
use 0xff for lightwhite, but that means brightblue in the simplest mode
(Truecolor depth 24).  Other modes are even more complicated -- they are
singly or doubly indirect throught palette(s) and changing of the palettes
by applications is supported.

Details:

Replicate the template value for Truecolor modes to fill out the target
depth (and more for depths not a multiple of 8).  Do this for every
drawing of the cursor so that it sort of works for mouse cursor bitmaps
set by applications.

Use 0xf for lightwhite in most other modes.  Only do this for the
default cursor so that it doesn't affect mouse cursor bitmaps set by
applications.  0xf mostly works because it was originally for CGA
lightwhite and is emulated using 1 or 2 indirections on EGA and VGA.
0x3f (EGA white) and 0xff (VGA black) direct palette indexes mostly
don't work since backwards compatibility inhibits or prevents them
representing lightwhite.  But 0x3f (EGA white) must be used for mode
37 (VGA_MODEX) (320x240x8 V) since this mode is closer to EGA than VGA.
2019-03-27 08:02:55 +00:00
Ed Maste
ed5e102abb DTF_REWIND does nothing (since r247236) so retire its use
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D19663
2019-03-26 19:35:41 +00:00
Martin Matuska
df422cb404 MFV r345495:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1153: fixed 2 bugs in ZIP reader [1]
  PR #1143: ensure archive_read_disk_entry_from_file() uses ARCHIVE_READ_DISK
  Changes to file flags code, support more file flags on FreeBSD:
    UF_OFFLINE, UF_READONLY, UF_SPARSE, UF_REPARSE, UF_SYSTEM
    UF_ARCHIVE is not supported by intention (yet)

PR:		236300
MFC after:	2 weeks
2019-03-25 11:49:57 +00:00
Bruce Evans
dac776fdbf Fix another type of buffer overrun for segmented modes. The buffer index
was not taken modulo the window size in VGLClear().

Segmented modes also need a kernel fix to almost work.  The ioctl to set
the window origin is broken.

These bugs are rarely problems since non-VESA modes only need
segmentation to support multiple pages but libvgl doesn't support
multiple pages and treats these modes as non-segmented, and VESA modes
are usually mapped linearly except on old hardware so they really are
non-segmented.
2019-03-25 11:48:40 +00:00
Bruce Evans
31d09534f8 Oops, my previous commit to libvgl was missing the change of VGLSetBorder()
to match the change in its declaration.  Change the declaration back to
"byte color" since setting of the border color is not supported for more
than 256 colors.
2019-03-24 20:43:21 +00:00
Bruce Evans
dd31deb8cb Fix the type of the color args for VGLMouseFreeze(), VGLBitmapPutChar(),
VGLBitmapString() and VGLSetBorder() so as to not truncate to 8 bits.

Complete the corresponding fix for VGLGetXY() and VGLPutXY() (parts
of the man page were out of date).
2019-03-24 20:36:35 +00:00
Bruce Evans
dd38752cb9 Add support for arbitrary font widths. Only multiples of 8 were supported.
Since the font format is undocumented, it is unclear how non-multiples
of 8 should be padded to bytes in the font file.  Use the same
representation as bdf text format (big- endian, with padding in the
lower bits).
2019-03-24 19:41:45 +00:00
Bruce Evans
1382e2a94d Fix reading of pixels in (4 and 8-plane) planar modes.
There seems to be no alternative to reading each plane independently using
3 slow i/o's per plane (this delivers 8 nearby pixels, but we don't buffer
the results so run 8 times slower than necessary.

All the code for this was there, but it was ifdefed out and replaced by
simpler code that cannot work in planar modes.  The ifdefed out code
was correct except it was missing a volatile declaration, so compilers
optimized the multiple dummy reads in it to a single read.
2019-03-24 19:27:03 +00:00
Bruce Evans
fbc6daa1dc Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used).  r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out.  In
the other ranges, only depth 15 is common.  It was broken by buffer
overruns in all cases.

bitmap.c:
- the static buffer was used even when it was too small (but it was
  large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
  constructor.  It often ended up as 0 for MEMBUFs, so using it in more
  places gave more null pointer accesses.  (It is per-bitmap, but since
  conversion between bitmaps of different depths is not supported (except
  from 4 bits by padding to 8), it would work better if it were global.)

main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
  was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes.  It isn't really
  used for frame buffer accesses in these modes, but needs to be 1 in
  MEMBUF images.

mouse.c:
- the mouse cursor buffers were too small.

vgl.h:
- PixelBytes was not initialized in the static bitmap constructor.  It
  should be initialized to the value for the current mode, but that is
  impossible in a static constructor.  Initialize it to -1 so as to
  fail if it is used without further initialization.

All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work.  Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns.  Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
Bruce Evans
425c24e5da Fix libvgl to not always fail to initialize due to its invalid mmap()
args (neither MAP_PRIVATE nor MAP_SHARED).  It was broken in r271635
and/or r271724 by stricter checking.  The compatibility code in r271724
doesn't work for my old binaries (actually new binaries with old
libraries).

PR:		needed to test the fix for PR 162373
2019-03-24 16:47:43 +00:00
Ravi Pokala
557e162fe7 Add descriptions for sysctls in kern_mib.c and sysctl.3 which lack them.
r343532 noted the difference between "hw.realmem" and "hw.physmem", which I
was previously unaware of. I discovered that neither sysctl had a
description visible via `sysctl -d', so I found where they were defined and
added suitable descriptions. While in the file, I went ahead and added
descriptions for all the others which lacked them. I also updated sysctl.3
accordingly

Reviewed by:	kib, bcr
MFC after:	1 weeks
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D19007
2019-03-23 19:53:15 +00:00
Conrad Meyer
481572a998 arc4random: Adjust example code to use uniform() API
PR:		236678
Reported by:	Andras Farkas <deepbluemistake AT gmail.com>
2019-03-21 14:45:08 +00:00
Alan Somers
bda54b8f96 googletest: backport GTEST_SKIP to googletest 1.8.1
This commit backports revisions 00938b2b228f3b70d3d9e51f29a1505bdad43f1e and
59f90a338bce2376b540ee239cf4e269bf6d68ad from googletest's master branch to
our included version of googletest, which is based on 1.8.1. It adds the
GTEST_SKIP feature, which is very useful for a project like FreeBSD where
some tests depend on particular system configurations.

Reviewed by:	ngie
Obtained from:	github.com/google/googletest
MFC after:	2 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/rS345331
2019-03-20 23:15:58 +00:00
Alan Somers
123af6ec70 Rename fuse(4) to fusefs(4)
This makes it more consistent with other filesystems, which all end in "fs",
and more consistent with its mount helper, which is already named
"mount_fusefs".

Reviewed by:	cem, rgrimes
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19649
2019-03-20 21:48:43 +00:00
Dimitry Andric
c3e6b9d390 Pull in r352826 from upstream lld trunk (by Fangrui Song):
[ELF] Support --{,no-}allow-shlib-undefined

  Summary:
  In ld.bfd/gold, --no-allow-shlib-undefined is the default when
  linking an executable. This patch implements a check to error on
  undefined symbols in a shared object, if all of its DT_NEEDED entries
  are seen.

  Our approach resembles the one used in gold, achieves a good balance
  to be useful but not too smart (ld.bfd traces all DSOs and emulates
  the behavior of a dynamic linker to catch more cases).

  The error is issued based on the symbol table, different from
  undefined reference errors issued for relocations. It is most
  effective when there are DSOs that were not linked with -z defs (e.g.
  when static sanitizers runtime is used).

  gold has a comment that some system libraries on GNU/Linux may have
  spurious undefined references and thus system libraries should be
  excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
  story may have changed now but we make --allow-shlib-undefined the
  default for now. Its interaction with -shared can be discussed in the
  future.

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: joerg, emaste, arichardson, llvm-commits

  Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

  [ELF] Default to --no-allow-shlib-undefined for executables

  Summary:
  This follows the ld.bfd/gold behavior.

  The error check is useful as it captures a common type of ld.so
  undefined symbol errors as link-time errors:

      // a.cc => a.so (not linked with -z defs)
      void f(); // f is undefined
      void g() { f(); }

      // b.cc => executable with a DT_NEEDED entry on a.so
      void g();
      int main() { g(); }

      // ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
      // symbol lookup error: ... undefined symbol: f

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: llvm-commits, emaste, arichardson

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by:	jbeich
PR:		236062, 236141
MFC after:	1 month
X-MFC-With:	r344779
2019-03-20 20:57:11 +00:00
Dimitry Andric
fb7e42b9fd Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365.  There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-20 19:18:26 +00:00
Dimitry Andric
d0010a8e4c Vendor import of clang 8.0.0 release r356365:
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_800/final@356365
2019-03-20 17:46:38 +00:00
Dimitry Andric
eccf47f57a Enable building libomp.so for 32-bit x86. This is done by selectively
enabling the functions that save and restore MXCSR, since access to this
register requires SSE support.

Note that you may run into other issues with OpenMP on i386, since this
*not* yet supported upstream, and certainly not extensively tested.

PR:		236062, 236582
MFC after:	1 month
X-MFC-With:	r344779
2019-03-18 21:04:28 +00:00
Dimitry Andric
66110c6521 Remove --as-needed from the linker flags for libomp.so, as these
actually prevent the transitive dependency on libm.

Reported by:	jbeich
PR:		236062, 236581
MFC after:	1 month
X-MFC-With:	r344779
2019-03-18 19:56:00 +00:00
Dimitry Andric
db7591a848 Also explicitly link libomp.so against -lm, as it transitively depends
on scalbn and a few other math functions, via libcompiler-rt.  This
should allow OpenMP programs to link with BFD linkers too.

Reported by:	jbeich
PR:		236062, 236581
MFC after:	1 month
X-MFC-With:	r344779
2019-03-18 19:11:11 +00:00
Dimitry Andric
1d0078a2af Explicitly link libomp.so against -lpthread, as it depends on pthread
functionality.  This should make example OpenMP programs work out of the
box.

Reported by:	jbeich
PR:		236062, 236581
MFC after:	1 month
X-MFC-With:	r344779
2019-03-17 11:27:27 +00:00
Dimitry Andric
9b3c15c583 Disable lib/libomp build for the 32-bit part of amd64 buildworld, as it
is not supported for that target.

Reported by:	Michael Butler <imb@protected-networks.net>
PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-16 17:55:22 +00:00
Dimitry Andric
b0840a28f6 Connect lib/libomp to the build.
* Set MK_OPENMP to yes by default only on amd64, for now.
* Bump __FreeBSD_version to signal this addition.
* Ensure gcc's conflicting omp.h is not installed if MK_OPENMP is yes.
* Update OptionalObsoleteFiles.inc to cope with the conflicting omp.h.
* Regenerate src.conf(5) with new WITH/WITHOUT fragments.

Relnotes:	yes
PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-16 15:45:15 +00:00
Dimitry Andric
3c6bb67129 Add lib/libomp, with a Makefile, and generated configuration headers.
Not connected to the main build yet, as there is still the issue of the
GNU omp.h header conflicting with the LLVM one.  (That is, if MK_GCC is
enabled.)

PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-16 15:01:36 +00:00
Enji Cooper
5193fcde8d Initial googlemock/googletest integration into the build/FreeBSD test suite
This initial integration takes googlemock/googletest release 1.8.1, integrates
the library, tests, and sample unit tests into the build.

googlemock/googletest's inclusion is optionally available via `MK_GOOGLETEST`.
`MK_GOOGLETEST` is dependent on `MK_TESTS` and is enabled by default when
built with a C++11 capable toolchain.

Google tests can be specified via the `GTESTS` variable, which, in comparison
with the other test drivers, is more simplified/streamlined, as Googletest only
supports C++ tests; not raw C or shell tests (C tests can be written in C++
using the standard embedding methods).

No dependent libraries are assumed for the tests. One must specify `gmock`,
`gmock_main`, `gtest`, or `gtest_main`, via `LIBADD` for the program.

More information about googlemock and googletest can be found on the
Googletest [project page](https://github.com/google/googletest), and the
[GoogleMock](https://github.com/google/googletest/blob/v1.8.x/googlemock/docs/Documentation.md)
and
[GoogleTest](https://github.com/google/googletest/tree/v1.8.x/googletest/docs)
docs.

These tests are originally integrated into the build as plain driver tests, but
will be natively integrated into Kyua in a later version.

Known issues/Errata:
* [WhenDynamicCastToTest.AmbiguousCast fails on FreeBSD](https://github.com/google/googletest/issues/2172)

Reviewed by:	asomers
Approved by:	emaste (mentor)
MFC after:	2 months
Differential Revision: https://reviews.freebsd.org/D19551
2019-03-15 21:43:52 +00:00
Dimitry Andric
2352f97079 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-14 19:52:12 +00:00
Dimitry Andric
54a27abbcb Vendor import of clang release_80 branch r356034:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@356034
2019-03-14 19:41:16 +00:00
Ed Maste
f6a10ccc53 Use consistent struct stat arg name in stat man page
stat, lstat, and fstat use `*sb` as the stat struct pointer arg name,
while fstatat previously used `*buf`.

MFC after:	1 week
2019-03-13 15:18:14 +00:00
John Baldwin
c8a048a4a3 Move libunwind out of contrib/llvm/projects.
Move LLVM's libunwind to its own contrib/ directory similar to other
runtime libraries like libc++ and libcxxrt.

Reviewed by:	dim, emaste
Differential Revision:	https://reviews.freebsd.org/D19534
2019-03-12 16:41:17 +00:00
Enji Cooper
ff511f1f39 MFhead@r344996 2019-03-11 03:02:58 +00:00
Dimitry Andric
b3ed818e2d Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR:		236062
MFC after:	1 month
X-MFC-With:	r344779
2019-03-09 00:27:50 +00:00
Dimitry Andric
f463519f0c Vendor import of clang release_80 branch r355677:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@355677
2019-03-08 22:44:50 +00:00
Mark Johnston
b16150ea90 Have pthread_cond_destroy() return EBUSY if the condvar has waiters.
This is not required of a compliant implementation, but it's easy to
check for and helps improve compatibility with other common
implementations.  Moreover, it's consistent with our
pthread_mutex_destroy().

PR:		234805
Reviewed by:	jhb, kib, ngie
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19496
2019-03-08 21:07:08 +00:00
John Baldwin
2e43efd0bb Drop "All rights reserved" from my copyright statements.
Reviewed by:	rgrimes
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D19485
2019-03-06 22:11:45 +00:00
Mark Johnston
f3af92bd36 Reorder copyright lines to preserve the source of "All rights reserved."
Reported by:	rgrimes
MFC with:	r344829, r344830
2019-03-06 16:50:14 +00:00
Marcin Wojtas
13ea0450a9 Extend libsecureboot(old libve) to obtain trusted certificates from UEFI and implement revocation
UEFI related headers were copied from edk2.

A new build option "MK_LOADER_EFI_SECUREBOOT" was added to allow
loading of trusted anchors from UEFI.

Certificate revocation support is also introduced.
The forbidden certificates are loaded from dbx variable.
Verification fails in two cases:

There is a direct match between cert in dbx and the one in the chain.
The CA used to sign the chain is found in dbx.
One can also insert a hash of TBS section of a certificate into dbx.
In this case verifications fails only if a direct match with a
certificate in chain is found.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: sjg
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision:	https://reviews.freebsd.org/D19093
2019-03-06 06:39:42 +00:00
Mark Johnston
5e58ed820a Add riscv minidump support to libkvm.
Submitted by:	Mitchell Horne <mhorne063@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D19171
2019-03-05 23:59:55 +00:00
Dimitry Andric
0a4621159b Add a few missed files to the MK_LLVM_TARGET_BPF=yes case, otherwise
clang and various other executables will fail to link with undefined
symbols.

Reported by:	O. Hartmann <ohartmann@walstatt.org>
MFC after:	1 month
X-MFC-With:	r344779
2019-03-05 22:04:23 +00:00
Ed Maste
80a8c751ea libllvm: promote WithColor and xxhash to SRCS_MIN
The armv6 build failed in CI due to missing symbols (from these two
source files) in the bootstrap Clang.

This affected only armv6 because other Clang-using archs are using LLD
as the bootstrap linker, and thus include SRCS_MIW via LLD_BOOTSTRAP.

Reported by:	CI, via lwhsu
Sponsored by:	The FreeBSD Foundation
2019-03-05 16:18:06 +00:00
Hans Petter Selasky
1efeb40d1d Fix typos in libusb.
Found by:		Denis Ahrens <denis@h3q.com>
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-03-05 14:47:15 +00:00
Enji Cooper
b18a4ccab9 MFhead@r344786 2019-03-05 01:00:38 +00:00
Simon J. Gerraty
02a4bc589c Allow for reproducible build
Use SOURCE_DATE_EPOCH for BUILD_UTC if MK_REPRODUCIBLE_BUILD is yes.
Default SOURCE_DATE_EPOCH to 2019-01-01

Reviewed by:	emaste
Sponsored by:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org/D19464
2019-03-04 22:04:21 +00:00
Dimitry Andric
844fc3e907 Merge ^/head r344549 through r344775. 2019-03-04 19:14:32 +00:00
Dimitry Andric
3087b115d4 Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.
2019-03-04 19:06:51 +00:00
Dimitry Andric
1dda0966cc Vendor import of clang release_80 branch r355313:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@355313
2019-03-04 18:25:50 +00:00
Dimitry Andric
1d6bb9f417 Vendor import of llvm release_80 branch r355313:
https://llvm.org/svn/llvm-project/llvm/branches/release_80@355313
2019-03-04 18:25:41 +00:00
Kenneth D. Merry
0caf9bf62d Add IBM TS1160 density codes to libmt and the mt(1) man page.
These are taken directly from the density report from a TS1160
tape drive.  (Using mt getdensity)

A TS1160 drive stores 20TB raw (60TB with compression) on a JE tape.

lib/libmt/mtlib.c:
	Add 3592A6 encrypted/unencrypted density codes, and bpmm/bpi
	values.

usr.bin/mt/mt.1:
	Add 3592B5 encrypted/unencrypted density codes, bpmm/bpi
	values and number of tracks.  Bump the man page date.

MFC after:	3 days
Sponsored by:	Spectra Logic
2019-03-04 14:30:37 +00:00
Michael Tuexen
8124c05f2c Use correct buffer sizes in sctp_get[lp]addrs().
MFC after:		3 days
2019-03-02 13:16:01 +00:00
Ed Maste
d95826c43d poll.2: POLLNVAL is returned also for insufficient rights
Reported by:	"Bora Özarslan" <borako.ozarslan@gmail.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-02-27 17:52:22 +00:00
Konstantin Belousov
9fb91a0a7d procctl(2): document ASLR knobs.
Reviewed by:	0mp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D19308
2019-02-26 17:41:41 +00:00
Konstantin Belousov
80a3fa4893 procctl(2): fix -width parameter to .Bl.
According to 0mp, macros are not expanded in the argument provided to
-width.  Use plain identifiers for width specification.

Noted and reviewed by:	0mp
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D19308
2019-02-26 17:35:06 +00:00
Simon J. Gerraty
a92958df34 Enable build of libbearssl
Reviewed by:	emaste
Sponsored by:	Juniper Networks
Differential Revision:	D16337
2019-02-26 06:11:01 +00:00
Simon J. Gerraty
5fff9558a4 Add libsecureboot
Used by loader and veriexec
Depends on libbearssl

Reviewed by:	emaste
Sponsored by:	Juniper Networks
Differential Revision:	D16335
2019-02-26 06:09:10 +00:00
Simon J. Gerraty
0957b409a9 Add libbearssl
Disabled by default, used by loader and sbin/veriexec

Reviewed by:	emaste
Sponsored by:	Juniper Networks
Differential Revision: D16334
2019-02-26 05:59:22 +00:00
Dimitry Andric
af373543d8 Merge ^/head r344513 through r344548. 2019-02-25 19:18:32 +00:00
Dimitry Andric
da18572fa1 Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.
2019-02-25 19:17:20 +00:00
Dimitry Andric
7b0060e442 Vendor import of clang release_80 branch r354799:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@354799
2019-02-25 19:07:25 +00:00
Dimitry Andric
bd7f07563c Vendor import of llvm release_80 branch r354799:
https://llvm.org/svn/llvm-project/llvm/branches/release_80@354799
2019-02-25 19:07:16 +00:00
Ed Maste
e1157dcec4 Make libifconfig INTERNALLIB
Instead of PRIVATELIB + NO_PIC.  This avoids the need for the wlandebug
PIE special case added in r344211, and provides a stronger guarantee
against 3rd party software coming to depend on the API or ABI.

If / when we declare the API/ABI to be stable we can make it a normal
library.

Discussed with:	bapt
Sponsored by:	The FreeBSD Foundation
2019-02-25 18:22:20 +00:00
Enji Cooper
18b18078f2 MFhead@r344527 2019-02-25 18:00:14 +00:00
Dimitry Andric
a8fe8db49a Merge ^/head r344178 through r344512. 2019-02-25 11:59:29 +00:00
Enji Cooper
7b42ad1434 Reword the comment above NO_WERROR 2019-02-21 06:51:35 +00:00
Enji Cooper
1d4fb286a0 Move NO_WTHREAD_SAFETY to googletest.test.inc.mk
This variable is necessary to compile with googletest at a global level. Move
it there.
2019-02-21 06:49:20 +00:00
Enji Cooper
c1bcc48b3c Use gmock/gtest headers when PRIVATELIB is defined
The move to /usr/include/private prefixed paths seems to require a bit more
effort in order to compile programs.

Install the headers to /usr/include/private/g{mock,test}/... and automatically
include /usr/include/private in GTESTS_CXXFLAGS to make compilation seamless. I
will work on the more global problem later with @bdrewery.
2019-02-21 04:47:44 +00:00
Enji Cooper
7481b4234c Build death tests programmatically
The previous code hardcoded the death test build definitions in a duplicative
manner. The new code doesn't.
2019-02-21 03:37:31 +00:00
Enji Cooper
833018816d Correct gmock/gtest expectations w.r.t. C++11/RTTI
Long story short, some of the tests were failing because they expected either
dynamic_cast or RTTI to be functional and it wasn't.

Move all common CXXFLAGS out to googletest.test.inc.mk and reference it from
googletest.test.mk and .../googletest/Makefile.inc
2019-02-20 20:09:59 +00:00
Konstantin Belousov
03d89f7a04 pkru(3) man page.
Reviewed by:	alc, markj, jilles
With more input from:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D19211
2019-02-20 10:03:03 +00:00
Konstantin Belousov
a2d95495ee Add usermode helpers for for Intel userspace protection keys feature.
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D18893
2019-02-20 09:56:23 +00:00
Enji Cooper
4783c2dda5 Fix test compilation for gmock_main tests, similar to r344345 2019-02-20 09:33:55 +00:00
Enji Cooper
4dedfa3214 Fix test compilation for gmock tests, similar to r344345 2019-02-20 08:04:08 +00:00
Enji Cooper
c5da30a59d Add glue Makefile.inc to make the next hop to the googletest/Makefile.inc 2019-02-20 08:01:00 +00:00
Enji Cooper
92ede4717e Oh wait... those helper programs were for the py tests
We don't need to install those. Leave that testing for the package's tests
2019-02-20 07:52:55 +00:00
Enji Cooper
140b363941 Apply lessons learned in r344345 on gtest_main tests
The key difference is that some of the programs were previously being compiled
and installed as tests, which is incorrect. Treat them like helpers instead.
2019-02-20 07:49:09 +00:00
Enji Cooper
dae8f2468d Fix gtest test compilation and build more tests
My previous work to integrate these tests was incomplete/incorrect, because I
misunderstood how the cmake macros worked.

This addresses items with the gtest tests, which in turn fixes test compilation
and adds more tests which I had previously missed.

Due to an unknown issue with gtest_stress_test, I had to add pthread to LIBADD,
even though I shouldn't have added it to that (it was failing to link -lpthread
to libprivategtest.a). Add a XXX comment to note that something's awry there
and deserves additional investigation.
2019-02-20 07:29:50 +00:00
Enji Cooper
f53e266234 Add more port-related flags to Makefile.inc 2019-02-20 06:54:32 +00:00
Enji Cooper
fedec5d9ee Sprinkle ${HAS_TESTS} in Makefiles
While here, reindent `SUBDIR.${MK_TESTS}`
2019-02-20 06:03:21 +00:00
Enji Cooper
04773d6d93 Add glue Makefile for tests under lib/googletest/... 2019-02-20 03:07:11 +00:00
Enji Cooper
988a9f7e39 Use GTESTS instead of PLAIN_TESTS_CXX
The former is from googletest.test.mk, whereas the latter is from plain.test.mk.

As noted in r344328, Kyua will adopt more native GoogleTest support. Thus, it's
more desirable to make the test interface more of an opaque blackbox for the
testcase implementer.
2019-02-20 01:11:30 +00:00
Enji Cooper
df13161740 Fix up dependency finding for libg{mock,test}_main
- Look up the corresponding non-*_main libraries via LDFLAGS using the
  directories provided in src.libnames.mk. This will allow the libraries to
  be built in the "make libraries" phase of buildworld.
- gtest_main relies on gtest, but didn't explicitly call out the dependency
  in `LIBADD`. Fill in this missing blank.
2019-02-20 00:19:11 +00:00
Enji Cooper
1ab321591f Unconditionally build/install libg{mock,test}_main
They are supporting libraries and as such, will need to be built/installed
when MK_TESTS == no during buildworld, i.e., the "make libraries" phase.

Otherwise, dependent components cannot rely on the libraries, like
`cddl/usr.sbin/zfsd/tests`.
2019-02-20 00:15:25 +00:00
Enji Cooper
f5817a3803 Add missing INCSGROUPS definition
This will install the gmock headers, like the gtest headers
2019-02-19 22:46:50 +00:00
Enji Cooper
43e25f47a7 Add MK_GOOGLETEST option for building/installing gmock/gtest
These libraries don't compile on non-C++-11 capable compilers, e.g., g++ 4.2.1
and its corresponding implementation of the c++ library, i.e., libstdc++.

Blacklist compilation on all non-C++-11 capable compilers and give others the
option of opting out of building/installing gmock/gtest via MK_GOOGLETEST.

This option is controlled by MK_CXX and MK_TESTS, as ATF compilation is.
2019-02-19 22:40:32 +00:00
Enji Cooper
c90e23db39 Make server_cat(..) handle short receives
In short, the prior code was far too simplistic when it came to calling recv(2)
and failed intermittently (or in the case of Jenkins, deterministically).

Handle short recv(2)s by checking the return code and incrementing the window
into the buffer by the number of received bytes. If the number of received
bytes <= 0, then bail out of the loop, and test the total number of received
bytes vs the expected number of bytes sent for equality, and base whether or
not the test passes/fails on that fact.

Remove the expected failure, now that the hdtr testcases deterministically pass
on my host after this change [1].

PR:		234809 [1], 235200
Reviewed by:	asomers
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D19188
2019-02-19 22:19:31 +00:00
Sean Eric Fagan
237f4abc57 Remove some redundant code in _posix1e_acl_strip_np
This was discovered through examination -- acl_copy_entry() copies the
tag type and permset fields.

Reviewed by:	trasz, pfg
Sponsored by:	iXsystems Inc.
Differential Revision:	https://reviews.freebsd.org/D19240
2019-02-19 19:15:15 +00:00
Enji Cooper
30e009fc3a MFhead@r344270 2019-02-19 03:46:32 +00:00
Gleb Smirnoff
aa43298309 With r343051 UMA switched from atomic counts to counter(9) and now kernel
reports snap counts of how much a zone alloced and how much it freed.  It
may happen that snap values doesn't match, e.g alloced - freed < 0.
Workaround that in memstat library.

Reported by:	pho
2019-02-18 21:27:13 +00:00
Dimitry Andric
40af08b3a3 Add one additional file to libllvmminimal, since in some cases (e.g.
upgrading from stable/10 to stable/11) symbols from it are needed to
link llvm-tblgen and clang-tblgen.

Reported by:	kib
MFC after:	3 days
2019-02-18 19:07:15 +00:00
Gleb Smirnoff
5bfb2e008d Imaginary cat jumped my keyboard! 2019-02-15 23:46:34 +00:00
Gleb Smirnoff
66fb0b1ad7 For 32-bit machines rollback the default number of vnode pager pbufs
back to the lever before r343030.  For 64-bit machines reduce it slightly,
too.  Together with r343030 I bumped the limit up to the value we use at
Netflix to serve 100 Gbit/s of sendfile traffic, and it probably isn't a
good default.

Provide a loader tunable to change vnode pager pbufs count. Document it.
2019-02-15 23:36:22 +00:00
Ed Maste
bcf99d2d99 Add WITH_PIE knob to build Position Independent Executables
Building binaries as PIE allows the executable itself to be loaded at a
random address when ASLR is enabled (not just its shared libraries).

With this change PIE objects have a .pieo extension and INTERNALLIB
libraries libXXX_pie.a.

MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as
they explicitly reference .a libraries in their Makefiles.  These can
be addressed on an individual basis later.  MK_PIE is also disabled for
rtld-elf because it is already position-independent using bespoke
Makefile rules.

Currently only dynamically linked binaries will be built as PIE.

Discussed with:	dim
Reviewed by:	kib
MFC after:	1 month
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18423
2019-02-15 22:22:38 +00:00
Dimitry Andric
c981cbbd13 Merge ^/head r343956 through r344177. 2019-02-15 21:50:45 +00:00
Dimitry Andric
640dd76f2c Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.
2019-02-15 21:44:42 +00:00
Dimitry Andric
8e85c80dd7 Vendor import of compiler-rt release_80 branch r354130:
https://llvm.org/svn/llvm-project/compiler-rt/branches/release_80@354130
2019-02-15 20:49:11 +00:00
Dimitry Andric
5df36aae64 Vendor import of clang release_80 branch r354130:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@354130
2019-02-15 20:49:05 +00:00
Dimitry Andric
519e1985ae Vendor import of llvm release_80 branch r354130:
https://llvm.org/svn/llvm-project/llvm/branches/release_80@354130
2019-02-15 20:48:51 +00:00
Konstantin Belousov
071bca67ee Unify i386 and amd64 getcontextx.c, and use ifuncs while there.
In particular, use ifuncs for __getcontextx_size(), also calculate the
size of the extended save area in resolver.  Same for __fillcontextx2().

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-02-14 14:02:33 +00:00
Konstantin Belousov
b5d72efb7a x86 __vdso_gettc(): use machine/cpufunc.h function for CPUID.
Based on the discussion with:	jkim
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-02-14 13:59:00 +00:00
Leandro Lupori
9031358d67 silence cast-align warnings from clang on powerpc64
silence the following warning when compiling libthr with clang 8
for powerpc64 architecture:

usr/src/lib/libthr/arch/powerpc/include/pthread_md.h:82:10: error:
cast from 'uint8_t *' (aka 'unsigned char *') to 'struct tcb *'
increases required alignment from 1 to 8 [-Werror,-Wcast-align]
82:  return ((struct tcb *)(_tp - TP_OFFSET));

Submitted by:	alfredo.junior_eldorado.org.br
Reviewed by:	git_bdragon.rtk0.net, emaste, kib, jhibbits, luporl
Differential Revision:	https://reviews.freebsd.org/D18807
2019-02-13 18:28:53 +00:00
Enji Cooper
fd89d5ad05 Compile the tests without -Werror for now
I'm working on resolving the issue upstream on github
2019-02-13 05:41:04 +00:00
Enji Cooper
f3c5273d31 Merge build glue for libraries and tests done on github
I need to doublecheck my work vs the port, but I believe that this covers the
initial integration of all upstream tests.

Ref: https://github.com/ngie-eign/freebsd/tree/googletest-integration
2019-02-13 04:58:15 +00:00
David E. O'Brien
60cc4a3e2d Note that readpassphrase() came into FreeBSD's libc at 4.6. 2019-02-13 04:52:01 +00:00
Kyle Evans
be7dd42376 libbe(3): Fix be_destroy behavior w.r.t. deep BE snapshots and -o
be_destroy is documented to recursively destroy a boot environment.  In the
case of snapshots, one would take this to mean that these are also
recursively destroyed.  However, this was previously not the case.
be_destroy would descend into the be_destroy callback and attempt to
zfs_iter_children on the top-level snapshot, which is bogus.

Our alternative approach is to take note of the snapshot name and iterate
through all of fs children of the BE to try destruction in the children.

The -o option is also fixed to work properly with deep BEs.  If the BE was
created with `bectl create -e otherDeepBE newDeepBE`, for instance, then a
recursive snapshot of otherDeepBE would have been taken for construction of
newDeepBE but a subsequent destroy with BE_DESTROY_ORIGIN set would only
clean up the snapshot at the root of otherDeepBE: ${BEROOT}/otherDeepBE@...

The most recent iteration instead pretends not to know how these things
work, verifies that the origin is another BE and then passes that back
through be_destroy to DTRT when snapshots and deep BEs may be in play.

MFC after:	1 week
2019-02-13 04:19:08 +00:00
Martin Matuska
a39fc08da2 MFV r344063:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1085: Fix a null pointer dereference bug in zip writer
  PR #1110: ZIP reader added support for XZ, LZMA, PPMD8 and BZIP2
            decopmpression
  PR #1116: Add support for 64-bit ar format
  PR #1120: Fix a 7zip crash [1] and a ISO9660 infinite loop [2]
  PR #1125: RAR5 reader - fix an invalid read and a memory leak
  PR #1131: POSIX reader - do not fail when tree_current_lstat() fails
            due to ENOENT [3]
  PR #1134: Delete unnecessary null pointer checks before calls of free()
  OSS-Fuzz 10843: Force intermediate to uint64_t to make UBSAN happy.
  OSS-Fuzz 11011: Avoid buffer overflow in rar5 reader

PR:		233006 [3]
Security:	CVE-2019-1000019 [1], CVE-2019-1000020 [2]
MFC after:	2 weeks
2019-02-12 23:24:45 +00:00
Kyle Evans
446ae812b0 libbe(3): Belatedly note the BE_DESTROY_ORIGIN option added in r343977
X-MFC-With: r343977
2019-02-12 02:16:21 +00:00
Mariusz Zaborski
b5d787d93b libnv: fix memory leaks
nvpair_create_stringv: free the temporary string; this fix affects
nvlist_add_stringf() and nvlist_add_stringv().

nvpair_remove_nvlist_array (NV_TYPE_NVLIST_ARRAY case): free the chain
of nvpairs (as resetting it prevents nvlist_destroy() from freeing it).
Note: freeing the chain in nvlist_destroy() is not sufficient, because
it would still leak through nvlist_take_nvlist_array().  This affects
all nvlist_*_nvlist_array() use

Submitted by:	Mindaugas Rasiukevicius <rmind@netbsd.org>
Reported by:	clang/gcc ASAN
MFC after:	2 weeks
2019-02-10 23:28:55 +00:00
Kyle Evans
13c62c50e3 libbe(3): Add a destroy option for removing the origin
Currently origin snapshots are left behind when a BE is destroyed, whether
it was an auto-created snapshot or explicitly specified via, for example,
`bectl create -e be@mysnap ...`.

Removing it automatically could be argued as a POLA violation in some
circumstances, so provide a flag to be_destroy for it. An accompanying
option will be added to bectl(8) to utilize this.

Some minor style/consistency nits in the affected areas also addressed.

Reported by:	Shawn Webb
MFC after:	1 week
2019-02-10 21:19:09 +00:00
Sergey Kandaurov
9b9a527843 Sync "struct addrinfo" declaration with netdb.h.
Notably, unlike in OpenBSD, which the man page was copied from,
ai_canonname and ai_addr come in different order.

PR:		225880
MFC after:	1 week
2019-02-10 19:07:47 +00:00
Dimitry Andric
9e43c218d5 Merge ^/head r343807 through r343955. 2019-02-10 12:49:34 +00:00
Peter Jeremy
885bfcda11 Replace calls to sin(x) and cos(x) with a single call to sincos().
Replace calls to sinf(x) and cosf(x) with a single call to sincosf().

Submitted by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
Reviewed by:	bde
Approved by:	grog
MFC after:	3 days
2019-02-10 08:46:07 +00:00
Sergey Kandaurov
78c8b9477c Document the ENOBUFS errno in setsockopt(2).
In particular, it is the case if SO_SNDBUF/SO_RCVBUF would exceed sb_max_adj.

PR:		200649
MFC after:	1 week
2019-02-09 21:33:32 +00:00
Dimitry Andric
bc8fc00705 Amend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and
trig_test.reduction test cases to fail, if the fixes from r343916 have
not yet been applied to the base compiler.

Reported by:    lwhsu
PR:		234040
Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after:	1 week
2019-02-08 18:31:54 +00:00
Dimitry Andric
94ba333f9c Pull in r352607 from upstream llvm trunk (by Craig Topper):
[X86] Add FPSW as a Def on some FP instructions that were missing it.

Pull in r353141 from upstream llvm trunk (by Craig Topper):

  [X86] Connect the default fpsr and dirflag clobbers in inline
  assembly to the registers we have defined for them.

  Summary:
  We don't currently map these constraints to physical register numbers
  so they don't make it to the MachineIR representation of inline
  assembly.

  This could have problems for proper dependency tracking in the
  machine schedulers though I don't have a test case that shows that.

  Reviewers: rnk

  Reviewed By: rnk

  Subscribers: eraman, llvm-commits

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D57641

Pull in r353489 from upstream llvm trunk (by Craig Topper):

  [X86] Add FPCW as a register and start using it as an implicit use on
  floating point instructions.

  Summary:
  FPCW contains the rounding mode control which we manipulate to
  implement fp to integer conversion by changing the roudning mode,
  storing the value to the stack, and then changing the rounding mode
  back. Because we didn't model FPCW and its dependency chain, other
  instructions could be scheduled into the middle of the sequence.

  This patch introduces the register and adds it as an implciit def of
  FLDCW and implicit use of the FP binary arithmetic instructions and
  store instructions. There are more instructions that need to be
  updated, but this is a good start. I believe this fixes at least the
  reduced test case from PR40529.

  Reviewers: RKSimon, spatel, rnk, efriedma, andrew.w.kaylor

  Subscribers: dim, llvm-commits

  Tags: #llvm

  Differential Revision: https://reviews.llvm.org/D57735

These should fix a problem in clang 7.0 where it would sometimes emit
long double floating point instructions in a slightly wrong order,
leading to failures in our libm tests.  In particular, the cbrt_test
test case 'cbrtl_powl' and the trig_test test case 'reduction'.

Also bump __FreeBSD_cc_version, to be able to detect this in our test
suite.

Reported by:    lwhsu
PR:		234040
Upstream PR:	https://bugs.llvm.org/show_bug.cgi?id=40206
MFC after:	1 week
2019-02-08 18:24:53 +00:00
Brooks Davis
60835849e5 GC a historical artifact.
Back in 1993, the fgetln (then fgetline) interface was changed to not
return a C string.  The change was accomplished by ifdefing out the code
that did the termination.  Changing the interface would violate our API
stability rules so remove the old implementation.

Sponsored by:	DARPA, AFRL
2019-02-07 23:17:44 +00:00
Sean Eric Fagan
18bb746b40 r343881 had an uninitialized error. This fixes that.
PR:             233849
Reported by:    Andre Albsmeier
MFC after:      1 month
Sponsored by:   iXsystems Inc
Differential Revision:  https://reviews.freebsd.org/D18785
2019-02-07 22:10:20 +00:00
Sean Eric Fagan
148d31b83d r339008 broke repquota for UFS. This rectifies that.
Refactor the function calls and tests so that, on UFS, the proper fields
are filled out.

PR:		233849
Reported by:	Andre Albsmeier
Reviewed by:	mav, delphij
MFC after:	1 month
Sponsored by:	iXsystems Inc
Differential Revision:	https://reviews.freebsd.org/D18785
2019-02-07 21:51:39 +00:00
Konstantin Belousov
fd90aeaabd Add comment noting that the strange spelling of GenuineIntel is for reason.
Requested by:	rpokala
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-02-07 03:58:29 +00:00
Konstantin Belousov
5925a98339 Use ifunc to select the barrier instruction for RDTSC.
This optimizes out runtime switch and removes yet another cpuid from
libc.

Note that this is the first use of ifunc in i386 libc, so
ifunc-capable toolchain is required for building runnable userspace on
i386, same as on amd64.

Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-02-07 02:56:10 +00:00
Jason A. Harmening
f048354550 r341692 changed cap_syslog(3) to preserve the stdio descriptors inherited
from its parent so that LOG_PERROR would work.  However, this caused
dhclient(8)'s stdio streams to remain open across daemonization, breaking
the ability to capture its foreground output as done in netconfig_ipv4.

Fix this by reverting r341692 and instead passing the parent's stderr
descriptor as an argument to cap_openlog() only when LOG_PERROR is specified
in logopt.

PR:	234514
Suggested by:	markj
Reported by:	Shawn Webb
Reviewed by:	markj, oshogbo
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18989
2019-02-06 04:36:28 +00:00
Dimitry Andric
8e69ae1c97 Merge ^/head r343712 through r343806. 2019-02-05 19:50:46 +00:00
Dimitry Andric
c8630eab15 Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.
2019-02-05 19:48:24 +00:00
Dimitry Andric
648606c4b5 Vendor import of compiler-rt release_80 branch r353167:
https://llvm.org/svn/llvm-project/compiler-rt/branches/release_80@353167
2019-02-05 18:39:32 +00:00
Dimitry Andric
d87c9e7da2 Vendor import of clang release_80 branch r353167:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@353167
2019-02-05 18:39:15 +00:00
Dimitry Andric
e79719ce60 Vendor import of llvm release_80 branch r353167:
https://llvm.org/svn/llvm-project/llvm/branches/release_80@353167
2019-02-05 18:38:58 +00:00
Matt Macy
334fd3dabc Fix deterministic builds by sorting input to fts in jevents
Reported by: emaste@
2019-02-05 00:31:25 +00:00
Warner Losh
52467047aa Regularize the Netflix copyright
Use recent best practices for Copyright form at the top of
the license:
1. Remove all the All Rights Reserved clauses on our stuff. Where we
   piggybacked others, use a separate line to make things clear.
2. Use "Netflix, Inc." everywhere.
3. Use a single line for the copyright for grep friendliness.
4. Use date ranges in all places for our stuff.

Approved by: Netflix Legal (who gave me the form), adrian@ (pmc files)
2019-02-04 21:28:25 +00:00
Konstantin Belousov
e4314da2e4 Fixes for very early use of the pthread_mutex_* and libthr malloc.
When libthr is statically linked into the binary, order of the
constructors execution is not deterministic.  It is possible for the
application constructor to use pthread_mutex_* functions before the
libthr initialization was done.

Handle it by:
- making thr_malloc.c locking functions operational when curthread is not
  yet set;
- making __thr_malloc_init() idempotent, allowing more than one call to it;
- unconditionally calling __thr_malloc_init() before initializing
  a process-private mutex.

Reported and tested by:	mmel
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-02-04 21:16:15 +00:00
Enji Cooper
8e0c33c6d3 Avoid the DNS lookup for "localhost"
ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test
VM), so in order for the test to pass on the host, it needs to avoid the DNS
lookup by using the numeric host address representation.

PR:		235200
Reviewed by:	asomers, lwhsu
Approved by:	emaste (mentor)
MFC after:	2 weeks
MFC with:	r343362, r343365, r343367-r343368, r343461
Differential Revision: https://reviews.freebsd.org/D19026
2019-02-04 19:12:45 +00:00
Michael Tuexen
bac4817b3a Add missing SCTP_EOR entry.
MFC after:		3 days
2019-02-04 13:30:47 +00:00
Dimitry Andric
c2c227a536 Merge ^/head r343571 through r343711. 2019-02-03 11:41:43 +00:00
Eric van Gyzen
50b06886a7 libm: squelch -Woverflow from gcc6
Sponsored by:	Dell EMC Isilon
2019-02-01 23:15:54 +00:00
Kyle Evans
9303f81955 libc/tests: Add test case for jemalloc/libthr bug fixed in r343566
Submitted by:	Andrew Gierth (original reproducer; kevans massaged for atf)
Reviewed by:	kib
MFC after:	2 weeks
X-MFC-with:	r343566 (or after)
Differential Revision:	https://reviews.freebsd.org/D19027
2019-01-31 02:49:24 +00:00
Konstantin Belousov
d49ca25de6 Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c.
Then malloc.c file name is too generic to use it for libthr.a.

Sponsored by:	The FreeBSD Foundation
MFC after:	13 days
2019-01-30 16:28:27 +00:00
Hans Petter Selasky
21be80ae80 Add support for Audio Sink and Audio Source profiles to sdpd(8).
This allows user-space programs like virtual_oss(8) to act
as a Bluetooth speaker device.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-01-30 09:44:54 +00:00
Dimitry Andric
7e565c552a Merge ^/head r343320 through r343570. 2019-01-30 07:10:33 +00:00
Konstantin Belousov
9a52756044 i386: Merge PAE and non-PAE pmaps into same kernel.
Effectively all i386 kernels now have two pmaps compiled in: one
managing PAE pagetables, and another non-PAE. The implementation is
selected at cold time depending on the CPU features. The vm_paddr_t is
always 64bit now. As result, nx bit can be used on all capable CPUs.

Option PAE only affects the bus_addr_t: it is still 32bit for non-PAE
configs, for drivers compatibility. Kernel layout, esp. max kernel
address, low memory PDEs and max user address (same as trampoline
start) are now same for PAE and for non-PAE regardless of the type of
page tables used.

Non-PAE kernel (when using PAE pagetables) can handle physical memory
up to 24G now, larger memory requires re-tuning the KVA consumers and
instead the code caps the maximum at 24G. Unfortunately, a lot of
drivers do not use busdma(9) properly so by default even 4G barrier is
not easy. There are two tunables added: hw.above4g_allow and
hw.above24g_allow, the first one is kept enabled for now to evaluate
the status on HEAD, second is only for dev use.

i386 now creates three freelists if there is any memory above 4G, to
allow proper bounce pages allocation. Also, VM_KMEM_SIZE_SCALE changed
from 3 to 1.

The PAE_TABLES kernel config option is retired.

In collaboarion with: pho
Discussed with:	emaste
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D18894
2019-01-30 02:07:13 +00:00
Konstantin Belousov
381c2d2e9a Untangle jemalloc and mutexes initialization.
The need to use libc malloc(3) from some places in libthr always
caused issues.  For instance, per-thread key allocation was switched to
use plain mmap(2) to get storage, because some third party mallocs
used keys for implementation of calloc(3).

Even more important, libthr calls calloc(3) during initialization of
pthread mutexes, and jemalloc uses pthread mutexes.  Jemalloc provides
some way to both postpone the initialization, and to make
initialization to use specialized allocator, but this is very fragile
and often breaks.  See the referenced PR for another example.

Add the small malloc implementation used by rtld, to libthr. Use it in
thr_spec.c and for mutexes initialization. This avoids the issues with
mutual dependencies between malloc and libthr in principle.  The
drawback is that some more allocations are not interceptable for
alternate malloc implementations.  There should be not too much memory
use from this allocator, and the alternative, direct use of mmap(2) is
obviously worse.

PR:	235211
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D18988
2019-01-29 22:46:44 +00:00
Konstantin Belousov
e5ac304989 Bump SPECNAMELEN to MAXNAMLEN.
This includes the bump for cdevsw d_version.  Otherwise, the impact on
the ABI (not KBI) is surprisingly low.  The most important affected
interface is devname(3) and ttyname(3) which already correctly handle
long names (and ttyname(3) should not be affected at all).

Still, due to the d_version bump, I argue that the change is not MFC-able.

Requested by:	mmacy
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D18932
2019-01-27 00:46:06 +00:00
Stefan Eßer
59ba78ccae Slightly improve previous commit that silenced a Clang Scan warning.
The strdup() call does not take advantage of the known length of the
source string. Replace by malloc() and memcpy() utilizimng the pre-
calculated string length.

Submitted by:	cperciva
Reported by:	rgrimes
MFC after:	2 weeks
2019-01-26 22:24:15 +00:00
Stefan Eßer
4268f3b3e0 Silence Clang Scan warning about potentially unsafe use of strcpy.
While this is a false positive, the use of strdup() simplifies the code.

MFC after:	2 weeks
2019-01-26 21:30:26 +00:00
Mariusz Zaborski
28f4385e45 libcasper: do not run registered exit functions
Casper library should not use exit(3) function because before setting it up
applications may register it. Casper doesn't depend on any registered exit
function, so it safe to change this.

Reported by:	jceel
MFC after:	2 weeks
2019-01-26 14:10:49 +00:00
Enji Cooper
4ce7bd2527 Fix reporting errors with gai_strerror(..)
The return value (`err`) should be checked; not the `errno` value.

PR:		235200
Approved by:	emaste (mentor)
Reviewed by:	asomers, lwhsu
MFC after:	28 days
MFC with:	r343362, r343365, r343367-r343368
Differential Revision: https://reviews.freebsd.org/D18969
2019-01-26 03:43:12 +00:00
Enji Cooper
2b9ecf4896 Document that sendfile will return an invalid value for sbytes if provided an invalid address
This is meant to clarify the fact that the system call will not fail
with -1/EFAULT, as one might expect, when reading the sendfile(2)
manpage today.

While here, pet the mandoc linter, when dealing with the section that
describes valid values for `flags`.

PR:	232210
MFC after:	2 weeks
Approved by:	emaste (mentor)
Reviewed by:	glebius, 0mp
Differential Revision: https://reviews.freebsd.org/D18949
2019-01-25 19:56:02 +00:00
Li-Wen Hsu
24df7b15fa Temporarily mark lib.msun.{cbrt_test.cbrtl_powl,trig_test.reduction}
expected failure after clang700-import merge

PR:		234040
Reviewed by:	ngie, markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18938
2019-01-25 18:48:20 +00:00
Enji Cooper
e190da54d3 Fix up r343367
I should have only changed the format qualifier with the `size_t` value,
`length`, not the other [`off_t`] value, `dest_file_size`.

MFC after:	1 month
MFC with:	r343362, r343365, r343367
Approved by:	emaste (mentor; implicit)
Reported by:	gcc 8.x
2019-01-23 23:48:57 +00:00
Enji Cooper
8dd6af34bc Unbreak the build on architectures where size_t isn't synonymous with uintmax_t
I should have used `%zu` instead of `%ju` with `size_t` types.

MFC after:	1 month
MFC with:	r343362, r343365
Approved by:	emaste (mentor; implicit)
Reviewed by:	asomers
Pointyhat to:	ngie
Submitted by:	asomers
Differential Revision: https://reviews.freebsd.org/D18935
2019-01-23 23:30:55 +00:00
Enji Cooper
de00e09d82 Unbreak the gcc build with sendfile_test after r343362
gcc 8.x is more pedantic than clang 7.x with format strings and the tests
passed `void*` variables while supplying `%s` (which is technically
incorrect).

Make the affected `void*` variables use `char*` storage instead to address
this issue, as the compiler will upcast the values to `char*`.

MFC after:	1 month
MFC with:	r343362
Approved by:	emaste (mentor; implicit)
Reviewed by:	asomers
Differential Revision: https://reviews.freebsd.org/D18934
2019-01-23 23:06:39 +00:00
Enji Cooper
b29e142648 Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile
These testcases exercise a number of functional requirements for sendfile(2).

The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed
functional on UFS and ZFS. UDP address family sockets cannot be used per the
sendfile(2) contract, thus using UDP sockets is outside the scope of
testing the syscall in positive cases. As seen in
`:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract
to ensure that EINVAL is returned by sendfile(2).

The testcases added explicitly avoid testing out `SF_SYNC` due to the
complexity of verifying that support. However, this is a good next logical
item to verify.

The `hdtr_positive*` testcases work to a certain degree (the header
testcases pass), but the trailer testcases do not work (it is an expected
failure). In particular, the value received by the mock server doesn't match
the expected value, and instead looks something like the following (using
python array notation):

`trailer[:]message[1:]`

instead of:

`message[:]trailer[:]`

This makes me think there's a buffer overrun issue or problem with the
offset somewhere in the sendfile(2) system call, but I need to do some
other testing first to verify that the code is indeed sane, and my
assumptions/code isn't buggy.

The `sbytes_negative` testcases that check `sbytes` being set to an
invalid value resulting in `EFAULT` fails today as the other change
(which checks `copyout(9)`) has not been committed [1]. Thus, it
should remain an expected failure (see bug 232210 for more details
on this item).

Next steps for testing sendfile(2):
1. Fix the header/trailer testcases so that they pass.
2. Setup if_tap interface and test with it, instead of using "localhost", per
   @asomers's suggestion.
3. Handle short recv(2)'s in `server_cat(..)`.
4. Add `SF_SYNC` support.
5. Add some more negative tests outside the scope of the functional contract.

MFC after:	1 month
Reviewed by:	asomers
Approved by:	emaste (mentor)
PR: 		232210
Sponsored by:   Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D18625
2019-01-23 22:00:17 +00:00
Kyle Evans
16ac070581 libbe(3): simplify import, allow replication streams
Previously, we directly used libzfs_core's lzc_receive to import to a
temporary snapshot, then cloned the snapshot and setup the properties. This
failed when attempting to import replication streams with questionable
error.

libzfs's zfs_receive is a much better fit here, so we now use it instead
with the destination dataset and let libzfs take care of the dirty details.
be_import is greatly simplified as a result.

Reported by:	Marie Helene Kvello-Aune <freebsd@mhka.no>
MFC after:	1 week
2019-01-23 02:09:15 +00:00
Dimitry Andric
88148a071b Merge ^/head r343202 through r343319. 2019-01-22 20:24:58 +00:00
Dimitry Andric
af44a0113e Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.
2019-01-22 20:24:10 +00:00
Dimitry Andric
8dabf201f0 Update compiler-rt build glue. 2019-01-22 20:08:25 +00:00
Dimitry Andric
58a7b5d64a Update libc++ build glue, and ObsoleteFiles. 2019-01-22 19:03:51 +00:00
Dimitry Andric
6e3f21a20c Update lldb build glue to make MK_LLDB=yes work. 2019-01-22 18:03:45 +00:00
Mark Johnston
504b5801bd List caph_limit_stream() in the synopsis.
Fix typos while here.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-01-21 20:56:29 +00:00
Dimitry Andric
efa7559714 Update llvm and clang build glue to make MK_CLANG_EXTRAS=yes and
MK_CLANG_FULL=yes work.
2019-01-21 19:39:35 +00:00
Dimitry Andric
5e86819c72 Add and remove sources from libllvm and libclang, to make the minimal
clang executable (with all options except targets off) build.
2019-01-21 06:52:55 +00:00
Dimitry Andric
676320a018 Update libllvmminimal and llvm-tblgen Makefiles, so llvm-tblgen and
clang-tblgen can build.
2019-01-20 18:53:32 +00:00
Dimitry Andric
0bf31f1fdc Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb.  Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.
2019-01-20 18:34:30 +00:00
Dimitry Andric
292698a853 Vendor import of clang release_80 branch r351543:
https://llvm.org/svn/llvm-project/cfe/branches/release_80@351543
2019-01-19 18:44:43 +00:00
Dimitry Andric
3edec5c15a Vendor import of llvm release_80 branch r351543:
https://llvm.org/svn/llvm-project/llvm/branches/release_80@351543
2019-01-19 18:44:22 +00:00
Dimitry Andric
e2fd426bda Vendor import of lld trunk r351319 (just before the release_80 branch
point):
https://llvm.org/svn/llvm-project/lld/trunk@351319
2019-01-19 10:05:49 +00:00
Dimitry Andric
6012fe9abb Vendor import of libc++ trunk r351319 (just before the release_80
branch point):
https://llvm.org/svn/llvm-project/libcxx/trunk@351319
2019-01-19 10:05:35 +00:00
Dimitry Andric
0646903fc1 Vendor import of compiler-rt trunk r351319 (just before the release_80
branch point):
https://llvm.org/svn/llvm-project/compiler-rt/trunk@351319
2019-01-19 10:05:08 +00:00
Dimitry Andric
676fbe8105 Vendor import of clang trunk r351319 (just before the release_80 branch
point):
https://llvm.org/svn/llvm-project/cfe/trunk@351319
2019-01-19 10:04:05 +00:00
Dimitry Andric
d8e91e4626 Vendor import of llvm trunk r351319 (just before the release_80 branch
point):
https://llvm.org/svn/llvm-project/llvm/trunk@351319
2019-01-19 10:01:25 +00:00
Dag-Erling Smørgrav
c9cf7cb85b Revert r343093 until I can address the issues raised by kib@. 2019-01-17 16:50:50 +00:00
Kirk McKusick
88640c0e8b Create new EINTEGRITY error with message "Integrity check failed".
An integrity check such as a check-hash or a cross-correlation failed.
The integrity error falls between EINVAL that identifies errors in
parameters to a system call and EIO that identifies errors with the
underlying storage media. EINTEGRITY is typically raised by intermediate
kernel layers such as a filesystem or an in-kernel GEOM subsystem when
they detect inconsistencies. Uses include allowing the mount(8) command
to return a different exit value to automate the running of fsck(8)
during a system boot.

These changes make no use of the new error, they just add it. Later
commits will be made for the use of the new error number and it will
be added to additional manual pages as appropriate.

Reviewed by:    gnn, dim, brueffer, imp
Discussed with: kib, cem, emaste, ed, jilles
Differential Revision: https://reviews.freebsd.org/D18765
2019-01-17 06:35:45 +00:00
Jilles Tjoelker
fbdcf603c8 libedit: Avoid out of bounds read in 'bind' command
This is CVS revision 1.31 from NetBSD lib/libedit/chartype.c:
Make sure that argv is NULL terminated since functions like tty_stty rely
on it to be so (Gerry Swinslow)

This broke when the wide-character support was enabled in libedit. The
conversion from multibyte to wide-character did not supply the apparently
expected terminating NULL in the new argv array.

PR:		233343
Submitted by:	Yuichiro NAITO
Obtained from:	NetBSD
MFC after:	1 week
2019-01-16 21:59:18 +00:00
Dag-Erling Smørgrav
9b35e90238 Implement dlopenat(3).
MFC after:	3 weeks
2019-01-16 12:12:40 +00:00
Konstantin Belousov
ea7e7006db Implement shmat(2) flag SHM_REMAP.
Based on the description in Linux man page.

Reviewed by:	markj, ngie (previous version)
Sponsored by:	Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18837
2019-01-16 05:15:57 +00:00
Gleb Smirnoff
cf64f5197b This was missed in r343051: make uz_allocs, uz_frees and uz_fails counter(9). 2019-01-15 18:47:19 +00:00
Gleb Smirnoff
bb15d1c778 o Move zone limit from keg level up to zone level. This means that now
two zones sharing a keg may have different limits. Now this is going
  to work:

  zone = uma_zcreate();
  uma_zone_set_max(zone, limit);
  zone2 = uma_zsecond_create(zone);
  uma_zone_set_max(zone2, limit2);

  Kegs no longer have uk_maxpages field, but zones have uz_items. When
  set, it may be rounded up to minimum possible CPU bucket cache size.
  For small limits bucket cache can also be reconfigured to be smaller.
  Counter uz_items is updated whenever items transition from keg to a
  bucket cache or directly to a consumer. If zone has uz_maxitems set and
  it is reached, then we are going to sleep.

o Since new limits don't play well with multi-keg zones, remove them. The
  idea of multi-keg zones was introduced exactly 10 years ago, and never
  have had a practical usage. In discussion with Jeff we came to a wild
  agreement that if we ever want to reintroduce the idea of a smart allocator
  that would be able to choose between two (or more) totally different
  backing stores, that choice should be made one level higher than UMA,
  e.g. in malloc(9) or in mget(), or whatever and choice should be controlled
  by the caller.

o Sleeping code is improved to account number of sleepers and wake them one
  by one, to avoid thundering herd problem.

o Flag UMA_ZONE_NOBUCKETCACHE removed, instead uma_zone_set_maxcache()
  KPI added. Having no bucket cache basically means setting maxcache to 0.

o Now with many fields added and many removed (no multi-keg zones!) make
  sure that struct uma_zone is perfectly aligned.

Reviewed by:	markj, jeff
Tested by:	pho
Differential Revision:	https://reviews.freebsd.org/D17773
2019-01-15 00:02:06 +00:00
Pedro F. Giffuni
76c528d350 msun: reduce diff between src/e_j0.c and src/e_j0f.c
PR:	229501
MFC after:	1 week
2019-01-14 15:48:35 +00:00
Justin Hibbits
5d031e332f Create crtsavres.o for powerpc builds
Summary:
GCC expects to link in a crtsavres.o on powerpc platforms.  On
powerpc64 this is an empty file, but on powerpc and powerpcspe this does contain
some save/restore functions, which may not actually be necessary for newer
modern GCC and clang.  This appeases the in-tree gcc, though, and is needed in
order to switch to the BSD CRTRBEGIN.

PR:	233751
Reviewed By: andrew
Differential Revision: https://reviews.freebsd.org/D18826
2019-01-12 21:29:54 +00:00
Cy Schubert
f2aac055e4 Disable FTS3, FTS4, and RTREE in bundled and private sqlite3.
Suggested by:	delphij@
Reviewed by:	delphij@ (for secteam@)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18786
2019-01-12 17:56:23 +00:00
Ed Maste
ae500c1ff8 Update to ELF Tool Chain r3668
Highlights:
- Make sure that only TLS sections are sorted into TLS segment.
- Fixed multiple errors in "Section to Segment mapping".
- Man page updates
- ar improvements
- elfcopy: avoid filter_reloc uninitialized variable for rela
- elfcopy: avoid stripping relocations from static binaries
- readelf: avoid printing directory in front of absolute path
- readelf: add NT_FREEBSD_FEATURE_CTL FreeBSD note type
- test improvements

NOTES:

Some of these changes originated in FreeBSD and simply reduce diffs
between contrib and vendor.

ELF Tool Chain ar is not (currently) used in FreeBSD, and there are
improvements in both FreeBSD and ELF Tool Chain ar that are not in
the other.

Sponsored by:	The FreeBSD Foundation
2019-01-10 14:35:23 +00:00
Kyle Evans
0a603a6ece libbe(3): Change be_mount to mount/unmount child datasets
This set of changes is geared towards making bectl respect deep boot
environments when they exist and are mounted. The deep BE composition
functionality (`bectl add`) remains disabled for the time being. This set of
changes has no effect for the average user. but allows deep BE users to
upgrade properly with their current setup.

libbe(3): Open the target boot environment and get a zfs handle, then pass
that with the target mountpoint to be_mount_iter; If the BE_MNT_DEEP flag is
set call zfs_iter_filesystems and mount the child datasets.

Similar logic is employed when unmounting the datasets, save for children
are unmounted first.

bectl(8): Change bectl_cmd_jail to pass the BE_MNT_DEEP flag when
calling be_mount as well as call be_unmount when cleaning up after the
jail has exited instead of umount(2) directly.

PR:		234795
Submitted by:	Wes Maag <jwmaag_gmail.com> (test additions by kevans)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D18796
2019-01-10 03:27:20 +00:00
Kyle Evans
fc13fc1c3a libbe(3): move altroot augmentation bits around a little bit
We could perhaps have a method that does this given a dataset, but it's yet
clear that we'll always want to bypass the altroot when we grab the
mountpoint. For now, we'll refactor things a bit so we grab the altroot
length when libbe is initialized and have a common method that does the
necessary augmentation (replace with / if it's the root, return a pointer to
later in the string if not).

This will be used in some upcoming work to make be_mount work properly for
deep BEs.

MFC after:	1 week
2019-01-09 22:31:10 +00:00
Xin LI
bf6e258bc4 Enable use of Capsicum sandbox when there is only one
input file (or the input is stdin) and we are not creating
output file.

Reported by:	Lasse Collin
MFC after:	1 month
2019-01-09 05:30:46 +00:00
Konstantin Belousov
3fbc2e00d1 Add a tunable which changes mincore(2) algorithm to only report data
from the local mapping.

Enable the setting by default.
The article behind the change: https://arxiv.org/abs/1901.01161

Reviewed by:	markj
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D18764
2019-01-07 22:10:48 +00:00
Pedro F. Giffuni
bdd8abc6d6 pow(3): Workaround possible signed shift Undefined Behavior.
j is int32_t and thus j<<31 is undefined if j==1.

Hinted by:	muusl-lib (git 688d3da0f1730daddbc954bbc2d27cc96ceee04c)
Discussed with:	freebsd-numerics (kargl)
2019-01-07 17:35:09 +00:00
Kyle Evans
f08dac4e90 libbe(3): Don't allow bootfs to be destroyed
Previously, the following sequence of events was feasible under some
circumstance:

bectl create test
bectl activate test
# the test BE dataset gets promoted and set as bootfs
bectl destroy test

I was unable to reproduce the destroy succeeding, but we should be rejecting
this before it even gets to libzfs because it would leave the system in an
inconsistent state. Forcing the user to be explicit as to which environment
should be activated instead is much better.

Reported by:	Graham Perrin <grahamperrin@gmail.com>
MFC after:	3 days
2019-01-07 16:16:47 +00:00
Jilles Tjoelker
8cc4b29d5a thr_wake(2): Minor mdoc fixes
MFC after:	1 week
2019-01-06 21:34:05 +00:00
Ed Maste
6871d48825 Add explicit csu test dependency
lib/csu/tests/dynamiclib requires libh_csu.so be built first.  I'm not
sure this is the most correct/best way to address this but it solves
the issue in my testing.

PR:		233734
Sponsored by:	The FreeBSD Foundation
2019-01-04 18:35:25 +00:00