vscsi_t2i() unused variable

2017-04-17 Thread Michael W. Bombardieri
Hello,

The variable rv in vscsi_t2i() appears to always be zero
and could be removed.

- Michael


Index: src/sys/dev/vscsi.c
===
RCS file: /cvs/src/sys/dev/vscsi.c,v
retrieving revision 1.41
diff -u -p -u -r1.41 vscsi.c
--- src/sys/dev/vscsi.c 12 Feb 2017 17:12:37 -  1.41
+++ src/sys/dev/vscsi.c 30 Mar 2017 08:16:27 -
@@ -429,7 +429,6 @@ vscsi_t2i(struct vscsi_softc *sc, struct
 {
struct vscsi_ccb*ccb;
struct scsi_xfer*xs;
-   int rv = 0;
 
TAILQ_FOREACH(ccb, >sc_ccb_t2i, ccb_entry) {
if (ccb->ccb_tag == t2i->tag)
@@ -464,7 +463,7 @@ vscsi_t2i(struct vscsi_softc *sc, struct
 
vscsi_done(sc, ccb);
 
-   return (rv);
+   return (0);
 }
 
 struct vscsi_devevent_task {



delete pf states by exact flow info and speed it up

2017-04-17 Thread YASUOKA Masahiko
Hi,

I'd like to add "key" modifier to "pfctl -k" to delete pf states, like
below:

  # pfctl -k key -k 'tcp 10.0.0.1:80 <- 10.0.0.101:32123'

This deletion will be very fast if the RB tree of pf state table is
used to find the state.  The diff also includes the diff for that part
(DIOCKILLSTATES of pf_ioctl).

comments?

ok?

Index: sbin/pfctl/pfctl.8
===
RCS file: /var/cvs/openbsd/src/sbin/pfctl/pfctl.8,v
retrieving revision 1.167
diff -u -p -r1.167 pfctl.8
--- sbin/pfctl/pfctl.8  26 Jan 2017 18:45:12 -  1.167
+++ sbin/pfctl/pfctl.8  12 Apr 2017 06:12:39 -
@@ -235,6 +235,7 @@ Kill all of the state entries matching t
 .Ar host ,
 .Ar network ,
 .Ar label ,
+.Ar key ,
 or
 .Ar id .
 .Pp
@@ -266,7 +267,7 @@ To kill all states with the target
 .Pp
 .Dl # pfctl -k 0.0.0.0/0 -k host2
 .Pp
-It is also possible to kill states by rule label or state ID.
+It is also possible to kill states by rule label, state key or state ID.
 In this mode the first
 .Fl k
 argument is used to specify the type
@@ -276,6 +277,17 @@ from rules carrying the label
 .Dq foobar :
 .Pp
 .Dl # pfctl -k label -k foobar
+.Pp
+To kill one specific state by its key
+(protocol, host1, port1, direction, host2 and port2 in the same format
+of pfctl -s state),
+use the
+.Ar key
+modifier and as a second argument the state key.
+To kill a state whose protocol is TCP and originating from
+10.0.0.101:32123 to 10.0.0.1:80 use:
+.Pp
+.Dl # pfctl -k key -k 'tcp 10.0.0.1:80 <- 10.0.0.101:32123'
 .Pp
 To kill one specific state by its unique state ID
 (as shown by pfctl -s state -vv),
Index: sbin/pfctl/pfctl.c
===
RCS file: /var/cvs/openbsd/src/sbin/pfctl/pfctl.c,v
retrieving revision 1.339
diff -u -p -r1.339 pfctl.c
--- sbin/pfctl/pfctl.c  27 Mar 2017 17:38:09 -  1.339
+++ sbin/pfctl/pfctl.c  12 Apr 2017 06:12:40 -
@@ -72,6 +72,8 @@ intpfctl_kill_src_nodes(int, const cha
 int pfctl_net_kill_states(int, const char *, int, int);
 int pfctl_label_kill_states(int, const char *, int, int);
 int pfctl_id_kill_states(int, int);
+int pfctl_key_kill_states(int, const char *, int, int);
+int pfctl_parse_host(char *, struct pf_rule_addr *);
 voidpfctl_init_options(struct pfctl *);
 int pfctl_load_options(struct pfctl *);
 int pfctl_load_limit(struct pfctl *, unsigned int, unsigned int);
@@ -683,6 +685,122 @@ pfctl_id_kill_states(int dev, int opts)
return (0);
 }
 
+int
+pfctl_key_kill_states(int dev, const char *iface, int opts, int rdomain)
+{
+   struct pfioc_state_kill psk;
+   char *s, *token, *tokens[4];
+   struct protoent *p;
+   u_int i, sidx, didx;
+
+   if (state_killers != 2 || (strlen(state_kill[1]) == 0)) {
+   warnx("no key specified");
+   usage();
+   }
+   memset(, 0, sizeof(psk));
+
+   if (iface != NULL && strlcpy(psk.psk_ifname, iface,
+   sizeof(psk.psk_ifname)) >= sizeof(psk.psk_ifname))
+   errx(1, "invalid interface: %s", iface);
+
+   psk.psk_rdomain = rdomain;
+
+   s = strdup(state_kill[1]);
+   if (!s)
+   errx(1, "pfctl_key_kill_states: strdup");
+   i = 0;
+   while ((token = strsep(, " \t")) != NULL)
+   if (*token != '\0') {
+   if (i < 4)
+   tokens[i] = token;
+   i++;
+   }
+   if (i != 4)
+   errx(1, "pfctl_key_kill_states: key must be \"protocol 
host1:port1 "
+   "direction host2:port2\" format");
+
+   if ((p = getprotobyname(tokens[0])) == NULL)
+   errx(1, "invalid protocol: %s", tokens[0]);
+   psk.psk_proto = p->p_proto;
+
+   if (strcmp(tokens[2], "->") == 0) {
+   sidx = 1;
+   didx = 3;
+   } else if (strcmp(tokens[2], "<-") == 0) {
+   sidx = 3;
+   didx = 1;
+   } else
+   errx(1, "invalid direction: %s", tokens[2]);
+
+   if (pfctl_parse_host(tokens[sidx], _src) == -1)
+   errx(1, "invalid host: %s", tokens[sidx]);
+   if (pfctl_parse_host(tokens[didx], _dst) == -1)
+   errx(1, "invalid host: %s", tokens[didx]);
+
+   if (ioctl(dev, DIOCKILLSTATES, ))
+   err(1, "DIOCKILLSTATES");
+
+   if ((opts & PF_OPT_QUIET) == 0)
+   fprintf(stderr, "killed %d states\n", psk.psk_killed);
+
+   return (0);
+}
+
+int
+pfctl_parse_host(char *str, struct pf_rule_addr *addr)
+{
+   char *s = NULL, *sbs, *sbe;
+   struct addrinfo hints, *ai;
+   struct sockaddr_in *sin4;
+   struct sockaddr_in6 *sin6;
+
+   s = strdup(str);
+   if (!s)
+   errx(1, "pfctl_parse_host: strdup");
+
+   memset(, 0, sizeof(hints));
+   hints.ai_socktype = SOCK_DGRAM; /* dummy */
+   hints.ai_flags = AI_NUMERICHOST;
+
+   if 

Re: CFI directives support in binutils

2017-04-17 Thread Joerg Sonnenberger
On Mon, Apr 17, 2017 at 10:45:37PM +0200, Mark Kettenis wrote:
> This diff extends the support for CFI in binutils with a few
> directives emitted by clang.  Most of the code is stolen from
> FreeBSD's GPLv2 binutils.  Support for the .cfi_sections directive is
> incomplete; basically we just ignore it.  Our binutils only support
> emitting frame info in the .eh_frame section.  Debuggers tend to fall
> back on .eh_frame if .dwarf_frame is missing, so this shouldn't be a
> problem.

The primary difference is that you can't easily strip .eh_frame from a
binary, so it adds overhead.

> This diff is necessary to build/use clang on sparc64 as there
> currently isn't an integrated assembler for the sparc64 target in
> llvm.

It exists, but it is missing parsing for a couple of tricky
instructions. Given that some central headers on NetBSD use inline
assembler with those, it never was very useful for me to enable IAS as
default on sparc64.

Joerg



CFI directives support in binutils

2017-04-17 Thread Mark Kettenis
This diff extends the support for CFI in binutils with a few
directives emitted by clang.  Most of the code is stolen from
FreeBSD's GPLv2 binutils.  Support for the .cfi_sections directive is
incomplete; basically we just ignore it.  Our binutils only support
emitting frame info in the .eh_frame section.  Debuggers tend to fall
back on .eh_frame if .dwarf_frame is missing, so this shouldn't be a
problem.  There is a small chance that a port will do an autoconf
check for this directive and make the wrong decision as the result of
this incomplete implementation.  The only autoconf check I can find
was in glibc though, so I'm not really worried.

This diff is necessary to build/use clang on sparc64 as there
currently isn't an integrated assembler for the sparc64 target in
llvm.

ok?


Index: gnu/usr.bin/binutils-2.17/gas/dw2gencfi.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/gas/dw2gencfi.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 dw2gencfi.c
--- gnu/usr.bin/binutils-2.17/gas/dw2gencfi.c   24 Apr 2011 20:14:44 -  
1.1.1.1
+++ gnu/usr.bin/binutils-2.17/gas/dw2gencfi.c   17 Apr 2017 20:32:56 -
@@ -21,6 +21,7 @@
 
 #include "as.h"
 #include "dw2gencfi.h"
+#include "subsegs.h"
 
 
 /* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
@@ -87,6 +88,10 @@ struct fde_entry
   symbolS *end_address;
   struct cfi_insn_data *data;
   struct cfi_insn_data **last;
+  unsigned char per_encoding;
+  unsigned char lsda_encoding;
+  expressionS personality;
+  expressionS lsda;
   unsigned int return_column;
   unsigned int signal_frame;
 };
@@ -97,15 +102,13 @@ struct cie_entry
   symbolS *start_address;
   unsigned int return_column;
   unsigned int signal_frame;
+  unsigned char per_encoding;
+  unsigned char lsda_encoding;
+  expressionS personality;
   struct cfi_insn_data *first, *last;
 };
 
 
-/* Current open FDE entry.  */
-static struct fde_entry *cur_fde_data;
-static symbolS *last_address;
-static offsetT cur_cfa_offset;
-
 /* List of FDE entries.  */
 static struct fde_entry *all_fde_data;
 static struct fde_entry **last_fde_data = _fde_data;
@@ -120,7 +123,14 @@ struct cfa_save_data
   offsetT cfa_offset;
 };
 
-static struct cfa_save_data *cfa_save_stack;
+/* Current open FDE entry.  */
+struct frch_cfi_data
+{
+  struct fde_entry *cur_fde_data;
+  symbolS *last_address;
+  offsetT cur_cfa_offset;
+  struct cfa_save_data *cfa_save_stack;
+};
 
 /* Construct a new FDE structure and add it to the end of the fde list.  */
 
@@ -129,12 +139,15 @@ alloc_fde_entry (void)
 {
   struct fde_entry *fde = xcalloc (1, sizeof (struct fde_entry));
 
-  cur_fde_data = fde;
+  frchain_now->frch_cfi_data = xcalloc (1, sizeof (struct frch_cfi_data));
+  frchain_now->frch_cfi_data->cur_fde_data = fde;
   *last_fde_data = fde;
   last_fde_data = >next;
 
   fde->last = >data;
   fde->return_column = DWARF2_DEFAULT_RETURN_COLUMN;
+  fde->per_encoding = DW_EH_PE_omit;
+  fde->lsda_encoding = DW_EH_PE_omit;
 
   return fde;
 }
@@ -149,6 +162,7 @@ static struct cfi_insn_data *
 alloc_cfi_insn_data (void)
 {
   struct cfi_insn_data *insn = xcalloc (1, sizeof (struct cfi_insn_data));
+  struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
 
   *cur_fde_data->last = insn;
   cur_fde_data->last = >next;
@@ -163,7 +177,7 @@ cfi_new_fde (symbolS *label)
 {
   struct fde_entry *fde = alloc_fde_entry ();
   fde->start_address = label;
-  last_address = label;
+  frchain_now->frch_cfi_data->last_address = label;
 }
 
 /* End the currently open FDE.  */
@@ -171,8 +185,9 @@ cfi_new_fde (symbolS *label)
 void 
 cfi_end_fde (symbolS *label)
 {
-  cur_fde_data->end_address = label;
-  cur_fde_data = NULL;
+  frchain_now->frch_cfi_data->cur_fde_data->end_address = label;
+  free (frchain_now->frch_cfi_data);
+  frchain_now->frch_cfi_data = NULL;
 }
 
 /* Set the return column for the current FDE.  */
@@ -180,7 +195,7 @@ cfi_end_fde (symbolS *label)
 void
 cfi_set_return_column (unsigned regno)
 {
-  cur_fde_data->return_column = regno;
+  frchain_now->frch_cfi_data->cur_fde_data->return_column = regno;
 }
 
 /* Universal functions to store new instructions.  */
@@ -239,10 +254,10 @@ cfi_add_advance_loc (symbolS *label)
   struct cfi_insn_data *insn = alloc_cfi_insn_data ();
 
   insn->insn = DW_CFA_advance_loc;
-  insn->u.ll.lab1 = last_address;
+  insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address;
   insn->u.ll.lab2 = label;
 
-  last_address = label;
+  frchain_now->frch_cfi_data->last_address = label;
 }
 
 /* Add a DW_CFA_offset record to the CFI data.  */
@@ -252,6 +267,7 @@ cfi_add_CFA_offset (unsigned regno, offs
 {
   unsigned int abs_data_align;
 
+  assert (DWARF2_CIE_DATA_ALIGNMENT != 0);
   cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset);
 
   abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0
@@ -266,7 +282,7 @@ void
 cfi_add_CFA_def_cfa (unsigned regno, offsetT offset)
 {
   

Re: tcpdump: decode BGP Administrative Shutdown Communication

2017-04-17 Thread Theo de Raadt
+   memset(string, 0, 129);
+   memcpy(string, p+1, shutdown_comm_length);
+   safeputs(string);

Please don't copy numbers like that.  If this is a string, why not
use string functions that gaurantee truncation and truncation detection...



Re: tcpdump: decode BGP Administrative Shutdown Communication

2017-04-17 Thread Job Snijders
Hi all,

Daan Keuper (Computest) was kind enough to review the diff, he pointed
out the following:

safeputs() expects a null-terminated string. Since shutdown_comm_length
won't exceed BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN (128), the
following will ensure a null-terminated string is passed to safeputs().

> + char string[128];
^^^
> + memset(string, 0, 128);
  ^^^
> + memcpy(string, p+1, shutdown_comm_length);
> + safeputs(string);

128 should be 129. oops!

I'd like to defer to more experienced programmers on the aesthetics of
using "129" rather then "BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN + 1",
or perhaps even an entirely other approach to ensure the string is
null-terminated.

Also added an additional check "shutdown_comm_length > (length -
BGP_NOTIFICATION_SIZE)" which is useful to prevent in case the shutdown
communication claims to be longer then the BGP message actually is.

Kind regards,

Job


diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c
index d028d671893..0886304926e 100644
--- a/usr.sbin/tcpdump/print-bgp.c
+++ b/usr.sbin/tcpdump/print-bgp.c
@@ -228,9 +228,13 @@ static const char *bgpnotify_minor_update[] = {
 
 /* RFC 4486 */
 #define BGP_NOTIFY_MINOR_CEASE_MAXPRFX  1
+/* draft-ietf-idr-shutdown-07 */
+#define BGP_NOTIFY_MINOR_CEASE_SHUT2
+#define BGP_NOTIFY_MINOR_CEASE_RESET   4
+#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  128
 static const char *bgpnotify_minor_cease[] = {
-   NULL, "Maximum Number of Prefixes Reached", "Administratively Shutdown",
-   "Peer De-configured", "Administratively Reset", "Connection Rejected",
+   NULL, "Maximum Number of Prefixes Reached", "Administrative Shutdown",
+   "Peer De-configured", "Administrative Reset", "Connection Rejected",
"Other Configuration Change", "Connection Collision Resolution",
"Out of Resources",
 };
@@ -302,6 +306,13 @@ static const char *afnumber[] = AFNUM_NAME_STR;
sizeof(afnumber)/sizeof(afnumber[0]), (x)))
 
 
+static void
+print_hex(const u_char *p, u_int len)
+{
+   while (len--)
+   printf("%02x", *p++);
+}
+
 static const char *
 num_or_str(const char **table, size_t siz, int value)
 {
@@ -996,6 +1007,9 @@ bgp_notification_print(const u_char *dat, int length)
u_int16_t af;
u_int8_t safi;
const u_char *p;
+   uint8_t shutdown_comm_length;
+   uint8_t remainder_offset;
+   char string[129];
 
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(, dat, BGP_NOTIFICATION_SIZE);
@@ -1026,9 +1040,56 @@ bgp_notification_print(const u_char *dat, int length)
 
printf(" Max Prefixes: %u", EXTRACT_32BITS(p+3));
}
+
+   /*
+* draft-ietf-idr-shutdown describes a method to send a
+* message intended for human consumption regarding the
+* Administrative Shutdown or Reset event. This is called
+* the "Shutdown Communication". The communication is
+* UTF-8 encoded and may be no longer than 128 bytes.
+*/
+
+   if ((bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_SHUT ||
+   bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) &&
+   (length >= BGP_NOTIFICATION_SIZE + 1)) {
+   p = dat + BGP_NOTIFICATION_SIZE;
+   TCHECK2(*p, 1);
+   shutdown_comm_length = *(p);
+   remainder_offset = 0;
+   /* seems we received garbage, hexdump it all */
+   if (shutdown_comm_length >
+   BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN ||
+   shutdown_comm_length > (length - 
BGP_NOTIFICATION_SIZE))
+   printf(", invalid Shutdown Communication 
length");
+   else if (shutdown_comm_length == 0) {
+   printf(", empty Shutdown Communication");
+   remainder_offset += 1;
+   }
+   /* a proper shutdown communication */
+   else {
+   TCHECK2(*(p+1), shutdown_comm_length);
+   printf(", Shutdown Communication (length: %u): 
\"",
+   shutdown_comm_length);
+   memset(string, 0, 129);
+   memcpy(string, p+1, shutdown_comm_length);
+   safeputs(string);
+   printf("\"");
+   remainder_offset += shutdown_comm_length + 1;
+   }
+   /* if there is trailing data, hexdump it */
+

sshd: Remove authorized_keys2 file

2017-04-17 Thread Klemens Nanni

Now that protocol version 1 was finally dropped in sshd(8), get rid of
this file completely. Our default sshd_config(5) overwrites
AuthorizedKeysFile to ignore it anyway and sshd(8)'s FILES section
doesn't mention it either.
Index: etc/changelist
===
RCS file: /cvs/src/etc/changelist,v
retrieving revision 1.116
diff -u -p -r1.116 changelist
--- etc/changelist  27 Feb 2017 21:53:11 -  1.116
+++ etc/changelist  17 Apr 2017 19:26:47 -
@@ -147,7 +147,6 @@
 /root/.rhosts
 /root/.shosts
 /root/.ssh/authorized_keys
-/root/.ssh/authorized_keys2
 /var/cron/at.allow
 /var/cron/at.deny
 /var/cron/cron.allow
Index: usr.bin/ssh/pathnames.h
===
RCS file: /cvs/src/usr.bin/ssh/pathnames.h,v
retrieving revision 1.25
diff -u -p -r1.25 pathnames.h
--- usr.bin/ssh/pathnames.h 31 Mar 2016 05:24:06 -  1.25
+++ usr.bin/ssh/pathnames.h 17 Apr 2017 19:26:47 -
@@ -79,7 +79,7 @@
 #define _PATH_SSH_USER_CONFFILE_PATH_SSH_USER_DIR "/config"
 
 /*
- * File containing a list of those rsa keys that permit logging in as this
+ * File containing a list of those keys that permit logging in as this
  * user.  This file need not be readable by anyone but the user him/herself,
  * but does not contain anything particularly secret.  If the user's home
  * directory resides on an NFS volume where root is mapped to nobody, this
@@ -87,9 +87,6 @@
  * running as root.)
  */
 #define _PATH_SSH_USER_PERMITTED_KEYS  _PATH_SSH_USER_DIR "/authorized_keys"
-
-/* backward compat for protocol v2 */
-#define _PATH_SSH_USER_PERMITTED_KEYS2 _PATH_SSH_USER_DIR "/authorized_keys2"
 
 /*
  * Per-user and system-wide ssh "rc" files.  These files are executed with
Index: usr.bin/ssh/servconf.c
===
RCS file: /cvs/src/usr.bin/ssh/servconf.c,v
retrieving revision 1.306
diff -u -p -r1.306 servconf.c
--- usr.bin/ssh/servconf.c  14 Mar 2017 07:19:07 -  1.306
+++ usr.bin/ssh/servconf.c  17 Apr 2017 19:26:47 -
@@ -294,12 +294,9 @@ fill_default_server_options(ServerOption
options->client_alive_interval = 0;
if (options->client_alive_count_max == -1)
options->client_alive_count_max = 3;
-   if (options->num_authkeys_files == 0) {
+   if (options->num_authkeys_files == 0)
options->authorized_keys_files[options->num_authkeys_files++] =
xstrdup(_PATH_SSH_USER_PERMITTED_KEYS);
-   options->authorized_keys_files[options->num_authkeys_files++] =
-   xstrdup(_PATH_SSH_USER_PERMITTED_KEYS2);
-   }
if (options->permit_tun == -1)
options->permit_tun = SSH_TUNMODE_NO;
if (options->ip_qos_interactive == -1)
Index: usr.bin/ssh/sshd.8
===
RCS file: /cvs/src/usr.bin/ssh/sshd.8,v
retrieving revision 1.288
diff -u -p -r1.288 sshd.8
--- usr.bin/ssh/sshd.8  30 Jan 2017 23:27:39 -  1.288
+++ usr.bin/ssh/sshd.8  17 Apr 2017 19:26:47 -
@@ -390,9 +390,7 @@ does not exist either, xauth is used to 
 specifies the files containing public keys for
 public key authentication;
 if this option is not specified, the default is
-.Pa ~/.ssh/authorized_keys
-and
-.Pa ~/.ssh/authorized_keys2 .
+.Pa ~/.ssh/authorized_keys .
 Each line of the file contains one
 key (empty lines and lines starting with a
 .Ql #
Index: usr.bin/ssh/sshd_config
===
RCS file: /cvs/src/usr.bin/ssh/sshd_config,v
retrieving revision 1.101
diff -u -p -r1.101 sshd_config
--- usr.bin/ssh/sshd_config 14 Mar 2017 07:19:07 -  1.101
+++ usr.bin/ssh/sshd_config 17 Apr 2017 19:26:47 -
@@ -35,9 +35,7 @@
 
 #PubkeyAuthentication yes
 
-# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
-# but this is overridden so installations will only check .ssh/authorized_keys
-AuthorizedKeysFile .ssh/authorized_keys
+#AuthorizedKeysFile.ssh/authorized_keys
 
 #AuthorizedPrincipalsFile none
 
Index: usr.bin/ssh/sshd_config.5
===
RCS file: /cvs/src/usr.bin/ssh/sshd_config.5,v
retrieving revision 1.243
diff -u -p -r1.243 sshd_config.5
--- usr.bin/ssh/sshd_config.5   14 Mar 2017 07:19:07 -  1.243
+++ usr.bin/ssh/sshd_config.5   17 Apr 2017 19:26:47 -
@@ -283,7 +283,7 @@ Alternately this option may be set to
 .Cm none
 to skip checking for user keys in files.
 The default is
-.Qq .ssh/authorized_keys .ssh/authorized_keys2 .
+.Qq .ssh/authorized_keys .
 .It Cm AuthorizedPrincipalsCommand
 Specifies a program to be used to generate the list of allowed
 certificate principals as per


Re: ld.lld: disable colors/bold/whatever

2017-04-17 Thread Patrick Wildt
On Mon, Apr 17, 2017 at 06:51:57PM +0200, Pascal Stumpf wrote:
> On Mon, 17 Apr 2017 18:25:34 +0200 (CEST), Mark Kettenis wrote:
> > > Date: Sun, 16 Apr 2017 22:00:23 +0200 (CEST)
> > > From: Mark Kettenis 
> > > 
> > > > Date: Sun, 16 Apr 2017 21:21:24 +0200
> > > > From: Patrick Wildt 
> > > > 
> > > > Hi,
> > > > 
> > > > this diff disables the color diagnostics by default so that LLVM's lld
> > > > does not throw any ANSI sequences.
> > > > 
> > > > ok?
> > > 
> > > Wouldn't it be better to just change
> > > lib/Support/Unix/Process.inc:terminalHasColors() to always return false?
> > > 
> > > that should take care of the color stuff in all the different llvm tools.
> > 
> > So here is a diff I was thinking of.  Fixes the issue that Theo
> > discovered.  I think this means the other diffs can be reverted, but
> > I'll do that in a separate diff.
> > 
> > ok?
> 
> #undef'ing HAVE_TERMINFO in config.h is a bit cleaner.  This also means
> that we can drop -ltermlib everywhere.  Note that this approach breaks
> colour autodetection (-fcolor-diagnostics=auto), but I don't think we
> care at this point.  Testing this diff now:

My attempt/commits tried to keep -fcolor-diagnostics=auto alive, but if
we don't want to go that route this diff is the way to go.

ok patrick@

> 
> 
> Index: clang/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- clang/Makefile27 Mar 2017 15:32:38 -  1.7
> +++ clang/Makefile17 Apr 2017 16:50:28 -
> @@ -9,9 +9,6 @@ SRCS= driver.cpp \
>   cc1_main.cpp \
>   cc1as_main.cpp
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  LINKS=   ${BINDIR}/clang ${BINDIR}/clang++ \
>   ${BINDIR}/clang ${BINDIR}/clang-cpp
>  MLINKS=  clang.1 clang++.1 \
> Index: include/llvm/Config/config.h
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/include/llvm/Config/config.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 config.h
> --- include/llvm/Config/config.h  24 Jan 2017 08:44:47 -  1.3
> +++ include/llvm/Config/config.h  17 Apr 2017 16:50:28 -
> @@ -242,7 +242,7 @@
>  #define HAVE_SYS_UIO_H 1
>  
>  /* Define if the setupterm() function is supported this platform. */
> -#define HAVE_TERMINFO 1
> +/* #undef HAVE_TERMINFO */
>  
>  /* Define if the xar_open() function is supported this platform. */
>  /* #undef HAVE_LIBXAR */
> Index: llc/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/llc/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- llc/Makefile  5 Sep 2016 10:56:50 -   1.1
> +++ llc/Makefile  17 Apr 2017 16:50:28 -
> @@ -3,9 +3,6 @@
>  PROG=llc
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  SRCS=llc.cpp
>  
>  .PATH: ${.CURDIR}/../../../llvm/tools/llc
> Index: lld/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- lld/Makefile  27 Mar 2017 15:32:38 -  1.7
> +++ lld/Makefile  17 Apr 2017 16:50:28 -
> @@ -7,9 +7,6 @@ BINDIR=   /usr/bin
>  SRCS=lld.cpp
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  .if ${COMPILER_VERSION:L} == "clang"
>  LINKS=   ${BINDIR}/ld.lld ${BINDIR}/ld
>  .endif
> 
> > Index: gnu/llvm/lib/Support/Unix/Process.inc
> > ===
> > RCS file: /cvs/src/gnu/llvm/lib/Support/Unix/Process.inc,v
> > retrieving revision 1.1.1.3
> > diff -u -p -r1.1.1.3 Process.inc
> > --- gnu/llvm/lib/Support/Unix/Process.inc   24 Jan 2017 08:33:36 -  
> > 1.1.1.3
> > +++ gnu/llvm/lib/Support/Unix/Process.inc   17 Apr 2017 16:21:16 -
> > @@ -342,7 +342,7 @@ static ManagedStatic TermCol
> >  #endif
> >  
> >  static bool terminalHasColors(int fd) {
> > -#ifdef HAVE_TERMINFO
> > +#if defined(HAVE_TERMINFO) && !defined(__OpenBSD__)
> >// First, acquire a global lock because these C routines are thread 
> > hostile.
> >MutexGuard G(*TermColorMutex);
> >  
> > 



Re: ld.lld: disable colors/bold/whatever

2017-04-17 Thread Mark Kettenis
> From: Pascal Stumpf 
> Date: Mon, 17 Apr 2017 18:51:57 +0200
> 
> On Mon, 17 Apr 2017 18:25:34 +0200 (CEST), Mark Kettenis wrote:
> > > Date: Sun, 16 Apr 2017 22:00:23 +0200 (CEST)
> > > From: Mark Kettenis 
> > > 
> > > > Date: Sun, 16 Apr 2017 21:21:24 +0200
> > > > From: Patrick Wildt 
> > > > 
> > > > Hi,
> > > > 
> > > > this diff disables the color diagnostics by default so that LLVM's lld
> > > > does not throw any ANSI sequences.
> > > > 
> > > > ok?
> > > 
> > > Wouldn't it be better to just change
> > > lib/Support/Unix/Process.inc:terminalHasColors() to always return false?
> > > 
> > > that should take care of the color stuff in all the different llvm tools.
> > 
> > So here is a diff I was thinking of.  Fixes the issue that Theo
> > discovered.  I think this means the other diffs can be reverted, but
> > I'll do that in a separate diff.
> > 
> > ok?
> 
> #undef'ing HAVE_TERMINFO in config.h is a bit cleaner.  This also means
> that we can drop -ltermlib everywhere.  Note that this approach breaks
> colour autodetection (-fcolor-diagnostics=auto), but I don't think we
> care at this point.  Testing this diff now:

ok kettenis@

> Index: clang/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- clang/Makefile27 Mar 2017 15:32:38 -  1.7
> +++ clang/Makefile17 Apr 2017 16:50:28 -
> @@ -9,9 +9,6 @@ SRCS= driver.cpp \
>   cc1_main.cpp \
>   cc1as_main.cpp
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  LINKS=   ${BINDIR}/clang ${BINDIR}/clang++ \
>   ${BINDIR}/clang ${BINDIR}/clang-cpp
>  MLINKS=  clang.1 clang++.1 \
> Index: include/llvm/Config/config.h
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/include/llvm/Config/config.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 config.h
> --- include/llvm/Config/config.h  24 Jan 2017 08:44:47 -  1.3
> +++ include/llvm/Config/config.h  17 Apr 2017 16:50:28 -
> @@ -242,7 +242,7 @@
>  #define HAVE_SYS_UIO_H 1
>  
>  /* Define if the setupterm() function is supported this platform. */
> -#define HAVE_TERMINFO 1
> +/* #undef HAVE_TERMINFO */
>  
>  /* Define if the xar_open() function is supported this platform. */
>  /* #undef HAVE_LIBXAR */
> Index: llc/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/llc/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- llc/Makefile  5 Sep 2016 10:56:50 -   1.1
> +++ llc/Makefile  17 Apr 2017 16:50:28 -
> @@ -3,9 +3,6 @@
>  PROG=llc
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  SRCS=llc.cpp
>  
>  .PATH: ${.CURDIR}/../../../llvm/tools/llc
> Index: lld/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- lld/Makefile  27 Mar 2017 15:32:38 -  1.7
> +++ lld/Makefile  17 Apr 2017 16:50:28 -
> @@ -7,9 +7,6 @@ BINDIR=   /usr/bin
>  SRCS=lld.cpp
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  .if ${COMPILER_VERSION:L} == "clang"
>  LINKS=   ${BINDIR}/ld.lld ${BINDIR}/ld
>  .endif
> 
> > Index: gnu/llvm/lib/Support/Unix/Process.inc
> > ===
> > RCS file: /cvs/src/gnu/llvm/lib/Support/Unix/Process.inc,v
> > retrieving revision 1.1.1.3
> > diff -u -p -r1.1.1.3 Process.inc
> > --- gnu/llvm/lib/Support/Unix/Process.inc   24 Jan 2017 08:33:36 -  
> > 1.1.1.3
> > +++ gnu/llvm/lib/Support/Unix/Process.inc   17 Apr 2017 16:21:16 -
> > @@ -342,7 +342,7 @@ static ManagedStatic TermCol
> >  #endif
> >  
> >  static bool terminalHasColors(int fd) {
> > -#ifdef HAVE_TERMINFO
> > +#if defined(HAVE_TERMINFO) && !defined(__OpenBSD__)
> >// First, acquire a global lock because these C routines are thread 
> > hostile.
> >MutexGuard G(*TermColorMutex);
> >  
> > 
> 
> 



Re: ld.lld: disable colors/bold/whatever

2017-04-17 Thread Mark Kettenis
> From: Pascal Stumpf 
> Date: Mon, 17 Apr 2017 18:51:57 +0200
> 
> On Mon, 17 Apr 2017 18:25:34 +0200 (CEST), Mark Kettenis wrote:
> > > Date: Sun, 16 Apr 2017 22:00:23 +0200 (CEST)
> > > From: Mark Kettenis 
> > > 
> > > > Date: Sun, 16 Apr 2017 21:21:24 +0200
> > > > From: Patrick Wildt 
> > > > 
> > > > Hi,
> > > > 
> > > > this diff disables the color diagnostics by default so that LLVM's lld
> > > > does not throw any ANSI sequences.
> > > > 
> > > > ok?
> > > 
> > > Wouldn't it be better to just change
> > > lib/Support/Unix/Process.inc:terminalHasColors() to always return false?
> > > 
> > > that should take care of the color stuff in all the different llvm tools.
> > 
> > So here is a diff I was thinking of.  Fixes the issue that Theo
> > discovered.  I think this means the other diffs can be reverted, but
> > I'll do that in a separate diff.
> > 
> > ok?
> 
> #undef'ing HAVE_TERMINFO in config.h is a bit cleaner.  This also means
> that we can drop -ltermlib everywhere.  Note that this approach breaks
> colour autodetection (-fcolor-diagnostics=auto), but I don't think we
> care at this point.  Testing this diff now:

I suppose that works as well.

> Index: clang/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- clang/Makefile27 Mar 2017 15:32:38 -  1.7
> +++ clang/Makefile17 Apr 2017 16:50:28 -
> @@ -9,9 +9,6 @@ SRCS= driver.cpp \
>   cc1_main.cpp \
>   cc1as_main.cpp
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  LINKS=   ${BINDIR}/clang ${BINDIR}/clang++ \
>   ${BINDIR}/clang ${BINDIR}/clang-cpp
>  MLINKS=  clang.1 clang++.1 \
> Index: include/llvm/Config/config.h
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/include/llvm/Config/config.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 config.h
> --- include/llvm/Config/config.h  24 Jan 2017 08:44:47 -  1.3
> +++ include/llvm/Config/config.h  17 Apr 2017 16:50:28 -
> @@ -242,7 +242,7 @@
>  #define HAVE_SYS_UIO_H 1
>  
>  /* Define if the setupterm() function is supported this platform. */
> -#define HAVE_TERMINFO 1
> +/* #undef HAVE_TERMINFO */
>  
>  /* Define if the xar_open() function is supported this platform. */
>  /* #undef HAVE_LIBXAR */
> Index: llc/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/llc/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- llc/Makefile  5 Sep 2016 10:56:50 -   1.1
> +++ llc/Makefile  17 Apr 2017 16:50:28 -
> @@ -3,9 +3,6 @@
>  PROG=llc
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  SRCS=llc.cpp
>  
>  .PATH: ${.CURDIR}/../../../llvm/tools/llc
> Index: lld/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- lld/Makefile  27 Mar 2017 15:32:38 -  1.7
> +++ lld/Makefile  17 Apr 2017 16:50:28 -
> @@ -7,9 +7,6 @@ BINDIR=   /usr/bin
>  SRCS=lld.cpp
>  NOMAN=
>  
> -LDADD+=  -ltermlib
> -DPADD+=  ${LIBTERMLIB}
> -
>  .if ${COMPILER_VERSION:L} == "clang"
>  LINKS=   ${BINDIR}/ld.lld ${BINDIR}/ld
>  .endif
> 
> > Index: gnu/llvm/lib/Support/Unix/Process.inc
> > ===
> > RCS file: /cvs/src/gnu/llvm/lib/Support/Unix/Process.inc,v
> > retrieving revision 1.1.1.3
> > diff -u -p -r1.1.1.3 Process.inc
> > --- gnu/llvm/lib/Support/Unix/Process.inc   24 Jan 2017 08:33:36 -  
> > 1.1.1.3
> > +++ gnu/llvm/lib/Support/Unix/Process.inc   17 Apr 2017 16:21:16 -
> > @@ -342,7 +342,7 @@ static ManagedStatic TermCol
> >  #endif
> >  
> >  static bool terminalHasColors(int fd) {
> > -#ifdef HAVE_TERMINFO
> > +#if defined(HAVE_TERMINFO) && !defined(__OpenBSD__)
> >// First, acquire a global lock because these C routines are thread 
> > hostile.
> >MutexGuard G(*TermColorMutex);
> >  
> > 
> 



Re: ld.lld: disable colors/bold/whatever

2017-04-17 Thread Pascal Stumpf
On Mon, 17 Apr 2017 18:25:34 +0200 (CEST), Mark Kettenis wrote:
> > Date: Sun, 16 Apr 2017 22:00:23 +0200 (CEST)
> > From: Mark Kettenis 
> > 
> > > Date: Sun, 16 Apr 2017 21:21:24 +0200
> > > From: Patrick Wildt 
> > > 
> > > Hi,
> > > 
> > > this diff disables the color diagnostics by default so that LLVM's lld
> > > does not throw any ANSI sequences.
> > > 
> > > ok?
> > 
> > Wouldn't it be better to just change
> > lib/Support/Unix/Process.inc:terminalHasColors() to always return false?
> > 
> > that should take care of the color stuff in all the different llvm tools.
> 
> So here is a diff I was thinking of.  Fixes the issue that Theo
> discovered.  I think this means the other diffs can be reverted, but
> I'll do that in a separate diff.
> 
> ok?

#undef'ing HAVE_TERMINFO in config.h is a bit cleaner.  This also means
that we can drop -ltermlib everywhere.  Note that this approach breaks
colour autodetection (-fcolor-diagnostics=auto), but I don't think we
care at this point.  Testing this diff now:


Index: clang/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/clang/clang/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- clang/Makefile  27 Mar 2017 15:32:38 -  1.7
+++ clang/Makefile  17 Apr 2017 16:50:28 -
@@ -9,9 +9,6 @@ SRCS=   driver.cpp \
cc1_main.cpp \
cc1as_main.cpp
 
-LDADD+=-ltermlib
-DPADD+=${LIBTERMLIB}
-
 LINKS= ${BINDIR}/clang ${BINDIR}/clang++ \
${BINDIR}/clang ${BINDIR}/clang-cpp
 MLINKS=clang.1 clang++.1 \
Index: include/llvm/Config/config.h
===
RCS file: /cvs/src/gnu/usr.bin/clang/include/llvm/Config/config.h,v
retrieving revision 1.3
diff -u -p -r1.3 config.h
--- include/llvm/Config/config.h24 Jan 2017 08:44:47 -  1.3
+++ include/llvm/Config/config.h17 Apr 2017 16:50:28 -
@@ -242,7 +242,7 @@
 #define HAVE_SYS_UIO_H 1
 
 /* Define if the setupterm() function is supported this platform. */
-#define HAVE_TERMINFO 1
+/* #undef HAVE_TERMINFO */
 
 /* Define if the xar_open() function is supported this platform. */
 /* #undef HAVE_LIBXAR */
Index: llc/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/clang/llc/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- llc/Makefile5 Sep 2016 10:56:50 -   1.1
+++ llc/Makefile17 Apr 2017 16:50:28 -
@@ -3,9 +3,6 @@
 PROG=  llc
 NOMAN=
 
-LDADD+=-ltermlib
-DPADD+=${LIBTERMLIB}
-
 SRCS=  llc.cpp
 
 .PATH: ${.CURDIR}/../../../llvm/tools/llc
Index: lld/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/clang/lld/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- lld/Makefile27 Mar 2017 15:32:38 -  1.7
+++ lld/Makefile17 Apr 2017 16:50:28 -
@@ -7,9 +7,6 @@ BINDIR= /usr/bin
 SRCS=  lld.cpp
 NOMAN=
 
-LDADD+=-ltermlib
-DPADD+=${LIBTERMLIB}
-
 .if ${COMPILER_VERSION:L} == "clang"
 LINKS= ${BINDIR}/ld.lld ${BINDIR}/ld
 .endif

> Index: gnu/llvm/lib/Support/Unix/Process.inc
> ===
> RCS file: /cvs/src/gnu/llvm/lib/Support/Unix/Process.inc,v
> retrieving revision 1.1.1.3
> diff -u -p -r1.1.1.3 Process.inc
> --- gnu/llvm/lib/Support/Unix/Process.inc 24 Jan 2017 08:33:36 -  
> 1.1.1.3
> +++ gnu/llvm/lib/Support/Unix/Process.inc 17 Apr 2017 16:21:16 -
> @@ -342,7 +342,7 @@ static ManagedStatic TermCol
>  #endif
>  
>  static bool terminalHasColors(int fd) {
> -#ifdef HAVE_TERMINFO
> +#if defined(HAVE_TERMINFO) && !defined(__OpenBSD__)
>// First, acquire a global lock because these C routines are thread 
> hostile.
>MutexGuard G(*TermColorMutex);
>  
> 



Re: ld.lld: disable colors/bold/whatever

2017-04-17 Thread Mark Kettenis
> Date: Sun, 16 Apr 2017 22:00:23 +0200 (CEST)
> From: Mark Kettenis 
> 
> > Date: Sun, 16 Apr 2017 21:21:24 +0200
> > From: Patrick Wildt 
> > 
> > Hi,
> > 
> > this diff disables the color diagnostics by default so that LLVM's lld
> > does not throw any ANSI sequences.
> > 
> > ok?
> 
> Wouldn't it be better to just change
> lib/Support/Unix/Process.inc:terminalHasColors() to always return false?
> 
> that should take care of the color stuff in all the different llvm tools.

So here is a diff I was thinking of.  Fixes the issue that Theo
discovered.  I think this means the other diffs can be reverted, but
I'll do that in a separate diff.

ok?


Index: gnu/llvm/lib/Support/Unix/Process.inc
===
RCS file: /cvs/src/gnu/llvm/lib/Support/Unix/Process.inc,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 Process.inc
--- gnu/llvm/lib/Support/Unix/Process.inc   24 Jan 2017 08:33:36 -  
1.1.1.3
+++ gnu/llvm/lib/Support/Unix/Process.inc   17 Apr 2017 16:21:16 -
@@ -342,7 +342,7 @@ static ManagedStatic TermCol
 #endif
 
 static bool terminalHasColors(int fd) {
-#ifdef HAVE_TERMINFO
+#if defined(HAVE_TERMINFO) && !defined(__OpenBSD__)
   // First, acquire a global lock because these C routines are thread hostile.
   MutexGuard G(*TermColorMutex);
 



softraid: Fixup concat

2017-04-17 Thread Thordur I. Bjornsson
Y'all,

During some refactoring work, the volume size calculation for the concat
discipline got lost, resulting in zero sized volumes.

http://secnorth.net/diffs/softraid-concat.diff:

diff --git a/sys/dev/softraid_concat.c b/sys/dev/softraid_concat.c
index 90cb12c8b6e..11fbf8ddb3f 100644
--- a/sys/dev/softraid_concat.c
+++ b/sys/dev/softraid_concat.c
@@ -60,12 +60,19 @@ int
 sr_concat_create(struct sr_discipline *sd, struct bioc_createraid *bc,
 int no_chunk, int64_t coerced_size)
 {
+ int i;
+
  if (no_chunk < 2) {
  sr_error(sd->sd_sc, "%s requires two or more chunks",
 sd->sd_name);
  return EINVAL;
 }

+ for (i = 0 ; i < no_chunk; i++) {
+ sd->sd_meta->ssdi.ssd_size +=
+sd->sd_vol.sv_chunks[i]->src_size;
+ }
+
  return sr_concat_init(sd);
 }


-- 
/ciao, thorduri.



Re: Fix regress/lib/libc/db

2017-04-17 Thread Todd C. Miller
On Mon, 17 Apr 2017 17:12:13 +0200, Mark Kettenis wrote:

> > From: "Todd C. Miller" 
> > Date: Mon, 17 Apr 2017 08:49:26 -0600
> > 
> > Maybe use UINT_MAX since st_size gets cast to u_int below?
> > Either way OK millert@
> 
> Already committed.  But INT_MAX is better anyway since there is a cast
> to int as well and INT_MAX < UINT_MAX.

Fair enough.

 - todd



Re: Fix regress/lib/libc/db

2017-04-17 Thread Mark Kettenis
> From: "Todd C. Miller" 
> Date: Mon, 17 Apr 2017 08:49:26 -0600
> 
> Maybe use UINT_MAX since st_size gets cast to u_int below?
> Either way OK millert@

Already committed.  But INT_MAX is better anyway since there is a cast
to int as well and INT_MAX < UINT_MAX.



Use correct libressl version in pkg-config

2017-04-17 Thread Steven McDonald
The pkg-config files for libcrypto and libssl claim to be version
1.0.0. This was noticed on the openvpn-devel mailing list when they
started requiring OpenSSL 1.0.1 or newer:

  https://sourceforge.net/p/openvpn/mailman/message/35785095/

While I don't think their approach of testing specific version numbers
is correct, it doesn't hurt to be consistent with what LibreSSL
portable reports. This diff is based on what LibreSSL portable does.

While here, also remove an old commented-out variable from before the
tree was reorganised.


Index: lib/libcrypto/generate_pkgconfig.sh
===
RCS file: /cvs/src/lib/libcrypto/generate_pkgconfig.sh,v
retrieving revision 1.2
diff -u -p -r1.2 generate_pkgconfig.sh
--- lib/libcrypto/generate_pkgconfig.sh 3 Sep 2016 12:42:46 -   1.2
+++ lib/libcrypto/generate_pkgconfig.sh 17 Apr 2017 14:32:29 -
@@ -50,10 +50,9 @@ if [ ! -w "${objdir}" ]; then
exit 1
 fi
 
-version_re="s/^#define[[:blank:]]+SHLIB_VERSION_NUMBER[[:blank:]]+\"(.*)\".*/\1/p"
-#version_file=${curdir}/src/crypto/opensslv.h
+version_re="s/^#define[[:blank:]]+LIBRESSL_VERSION_TEXT[[:blank:]]+\"LibreSSL 
(.*)\".*/\1/p"
 version_file=${curdir}/opensslv.h
-lib_version=$(sed -nE ${version_re} ${version_file})
+lib_version=$(sed -nE "${version_re}" "${version_file}")
 
 # Put -I${includedir} into Cflags so configure script tests like
 #   test -n "`pkg-config --cflags openssl`"
@@ -66,8 +65,8 @@ exec_prefix=\${prefix}
 libdir=\${exec_prefix}/lib
 includedir=\${prefix}/include
 
-Name: OpenSSL-libcrypto
-Description: OpenSSL cryptography library
+Name: LibreSSL-libcrypto
+Description: LibreSSL cryptography library
 Version: ${lib_version}
 Requires: 
 Libs: -L\${libdir} -lcrypto
Index: lib/libssl/generate_pkgconfig.sh
===
RCS file: /cvs/src/lib/libssl/generate_pkgconfig.sh,v
retrieving revision 1.9
diff -u -p -r1.9 generate_pkgconfig.sh
--- lib/libssl/generate_pkgconfig.sh3 Sep 2016 12:42:42 -   1.9
+++ lib/libssl/generate_pkgconfig.sh17 Apr 2017 14:32:29 -
@@ -50,9 +50,9 @@ if [ ! -w "${objdir}" ]; then
exit 1
 fi
 
-version_re="s/^#define[[:blank:]]+SHLIB_VERSION_NUMBER[[:blank:]]+\"(.*)\".*/\1/p"
+version_re="s/^#define[[:blank:]]+LIBRESSL_VERSION_TEXT[[:blank:]]+\"LibreSSL 
(.*)\".*/\1/p"
 version_file=${curdir}/../libcrypto/opensslv.h
-lib_version=$(sed -nE ${version_re} ${version_file})
+lib_version=$(sed -nE "${version_re}" "${version_file}")
 
 # Put -I${includedir} into Cflags so configure script tests like
 #   test -n "`pkg-config --cflags openssl`"
@@ -65,7 +65,7 @@ exec_prefix=\${prefix}
 libdir=\${exec_prefix}/lib
 includedir=\${prefix}/include
 
-Name: OpenSSL
+Name: LibreSSL-libssl
 Description: Secure Sockets Layer and cryptography libraries
 Version: ${lib_version}
 Requires: 
@@ -81,7 +81,7 @@ exec_prefix=\${prefix}
 libdir=\${exec_prefix}/lib
 includedir=\${prefix}/include
 
-Name: OpenSSL
+Name: LibreSSL
 Description: Secure Sockets Layer and cryptography libraries and tools
 Version: ${lib_version}
 Requires: 



Re: Fix regress/lib/libc/db

2017-04-17 Thread Todd C. Miller
Maybe use UINT_MAX since st_size gets cast to u_int below?
Either way OK millert@

 - todd



Re: tcpdump: decode BGP Administrative Shutdown Communication

2017-04-17 Thread Job Snijders
Hi OpenBSD,

bgpd(8) as shipped in OpenBSD 6.1 supports draft-ietf-idr-shutdown-07.
The below patch adds support to tcpdump(8) to decode such shutdown
communication.

This is an improved version of the patch proposal I sent in January.

Kind regards,

Job



diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c
index d028d671893..2871b92909f 100644
--- a/usr.sbin/tcpdump/print-bgp.c
+++ b/usr.sbin/tcpdump/print-bgp.c
@@ -228,9 +228,13 @@ static const char *bgpnotify_minor_update[] = {
 
 /* RFC 4486 */
 #define BGP_NOTIFY_MINOR_CEASE_MAXPRFX  1
+/* draft-ietf-idr-shutdown-07 */
+#define BGP_NOTIFY_MINOR_CEASE_SHUT2
+#define BGP_NOTIFY_MINOR_CEASE_RESET   4
+#define BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN  128
 static const char *bgpnotify_minor_cease[] = {
-   NULL, "Maximum Number of Prefixes Reached", "Administratively Shutdown",
-   "Peer De-configured", "Administratively Reset", "Connection Rejected",
+   NULL, "Maximum Number of Prefixes Reached", "Administrative Shutdown",
+   "Peer De-configured", "Administrative Reset", "Connection Rejected",
"Other Configuration Change", "Connection Collision Resolution",
"Out of Resources",
 };
@@ -302,6 +306,13 @@ static const char *afnumber[] = AFNUM_NAME_STR;
sizeof(afnumber)/sizeof(afnumber[0]), (x)))
 
 
+static void
+print_hex(const u_char *p, u_int len)
+{
+   while (len--)
+   printf("%02x", *p++);
+}
+
 static const char *
 num_or_str(const char **table, size_t siz, int value)
 {
@@ -996,6 +1007,9 @@ bgp_notification_print(const u_char *dat, int length)
u_int16_t af;
u_int8_t safi;
const u_char *p;
+   uint8_t shutdown_comm_length;
+   uint8_t remainder_offset;
+   char string[128];
 
TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(, dat, BGP_NOTIFICATION_SIZE);
@@ -1026,9 +1040,55 @@ bgp_notification_print(const u_char *dat, int length)
 
printf(" Max Prefixes: %u", EXTRACT_32BITS(p+3));
}
+
+   /*
+* draft-ietf-idr-shutdown describes a method to send a
+* message intended for human consumption regarding the
+* Administrative Shutdown or Reset event. This is called
+* the "Shutdown Communication". The communication is
+* UTF-8 encoded and may be no longer than 128 bytes.
+*/
+
+   if ((bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_SHUT ||
+   bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) &&
+   (length >= BGP_NOTIFICATION_SIZE + 1)) {
+   p = dat + BGP_NOTIFICATION_SIZE;
+   TCHECK2(*p, 1);
+   shutdown_comm_length = *(p);
+   remainder_offset = 0;
+   /* seems we received garbage, hexdump it all */
+   if (shutdown_comm_length >
+   BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN)
+   printf(", invalid Shutdown Communication 
length");
+   else if (shutdown_comm_length == 0) {
+   printf(", empty Shutdown Communication");
+   remainder_offset += 1;
+   }
+   /* a proper shutdown communication */
+   else {
+   TCHECK2(*(p+1), shutdown_comm_length);
+   printf(", Shutdown Communication (length: %u): 
\"",
+   shutdown_comm_length);
+   memset(string, 0, 128);
+   memcpy(string, p+1, shutdown_comm_length);
+   safeputs(string);
+   printf("\"");
+   remainder_offset += shutdown_comm_length + 1;
+   }
+   /* if there is trailing data, hexdump it */
+   if (length -
+   (remainder_offset + BGP_NOTIFICATION_SIZE) > 0) {
+   printf(", Data: (length: %u) ",
+   length - (remainder_offset +
+   BGP_NOTIFICATION_SIZE));
+   print_hex(p + remainder_offset, length -
+   (remainder_offset + BGP_NOTIFICATION_SIZE));
+   }
+   }
}
 
return;
+
 trunc:
printf("[|BGP]");
 }



Re: start building clang alongside gcc on amd64

2017-04-17 Thread Steven McDonald
On Mon, 17 Apr 2017 09:20:21 +0200 (CEST)
Mark Kettenis  wrote:

> These instructions may not be 100% accurate yet ;).

I also had to build libcxx before doing a full build:

# cd /usr/src/lib/libcxx
# make obj
# make depend
# make includes
# make
# make install



sparc64 libunwind

2017-04-17 Thread Mark Kettenis
The diff below adds sparc64 support to libunwind.  With this diff I
can build libc++abi and libc++ on sparc64.  The exception handling
regress tests in src/regress/misc pass when compiled with clang/clang++.

The sparc64 unwinder is a little bit more complicated than the others
since it has to handle StackGhost.  I'm not 100% sure StackGhost is
handled correctly in all corner cases, but it seems to work.

I'll try to upstream this code.

ok?


Index: include/__libunwind_config.h
===
RCS file: /cvs/src/lib/libunwind/include/__libunwind_config.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 __libunwind_config.h
--- include/__libunwind_config.h3 Sep 2016 18:42:12 -   1.1.1.1
+++ include/__libunwind_config.h17 Apr 2017 10:46:29 -
@@ -53,6 +53,11 @@
 #  define _LIBUNWIND_CONTEXT_SIZE 16
 #  define _LIBUNWIND_CURSOR_SIZE 28
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
+# elif defined(__sparc__) && defined(__arch64__)
+#  define _LIBUNWIND_TARGET_SPARC64 1
+#  define _LIBUNWIND_CONTEXT_SIZE 33
+#  define _LIBUNWIND_CURSOR_SIZE 45
+#  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 32
 # else
 #  error "Unsupported architecture."
 # endif
Index: src/DwarfInstructions.hpp
===
RCS file: /cvs/src/lib/libunwind/src/DwarfInstructions.hpp,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 DwarfInstructions.hpp
--- src/DwarfInstructions.hpp   3 Sep 2016 18:42:12 -   1.1.1.1
+++ src/DwarfInstructions.hpp   17 Apr 2017 10:46:29 -
@@ -85,6 +85,10 @@ typename A::pint_t DwarfInstructions::getSaved
   case CFI_Parser::kRegisterUnused:
   case CFI_Parser::kRegisterOffsetFromCFA:
   case CFI_Parser::kRegisterInRegister:
+  case CFI_Parser::kRegisterInCFADecrypt:
 // FIX ME
 break;
   }
@@ -145,6 +150,7 @@ v128 DwarfInstructions::getSavedVe
   case CFI_Parser::kRegisterUnused:
   case CFI_Parser::kRegisterOffsetFromCFA:
   case CFI_Parser::kRegisterInRegister:
+  case CFI_Parser::kRegisterInCFADecrypt:
 // FIX ME
 break;
   }
Index: src/DwarfParser.hpp
===
RCS file: /cvs/src/lib/libunwind/src/DwarfParser.hpp,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 DwarfParser.hpp
--- src/DwarfParser.hpp 3 Sep 2016 18:42:12 -   1.1.1.1
+++ src/DwarfParser.hpp 17 Apr 2017 10:46:29 -
@@ -67,6 +67,7 @@ public:
   enum RegisterSavedWhere {
 kRegisterUnused,
 kRegisterInCFA,
+kRegisterInCFADecrypt,
 kRegisterOffsetFromCFA,
 kRegisterInRegister,
 kRegisterAtExpression,
@@ -663,6 +664,18 @@ bool CFI_Parser::parseInstructions(A 
 fprintf(stderr, "DW_CFA_val_expression(reg=%" PRIu64
 ", expression=0x%" PRIx64 ", length=%" PRIu64 ")\n",
 reg, results->savedRegisters[reg].value, length);
+  break;
+case DW_CFA_GNU_window_save:
+  // Hardcodes windowed registers for SPARC
+  for (reg = 16; reg < 32; reg++) {
+   if (reg == 31)
+ results->savedRegisters[reg].location = kRegisterInCFADecrypt;
+   else
+ results->savedRegisters[reg].location = kRegisterInCFA;
+   results->savedRegisters[reg].value = (reg - 16) * sizeof(pint_t);
+  }
+  if (logDwarf)
+   fprintf(stderr, "DW_CGA_GNU_window_save\n");
   break;
 case DW_CFA_GNU_args_size:
   length = addressSpace.getULEB128(p, instructionsEnd);
Index: src/Registers.hpp
===
RCS file: /cvs/src/lib/libunwind/src/Registers.hpp,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Registers.hpp
--- src/Registers.hpp   3 Sep 2016 18:42:12 -   1.1.1.1
+++ src/Registers.hpp   17 Apr 2017 10:46:29 -
@@ -62,6 +62,7 @@ public:
   void  setESI(uint32_t value) { _registers.__esi = value; }
   uint32_t  getEDI() const { return _registers.__edi; }
   void  setEDI(uint32_t value) { _registers.__edi = value; }
+  uint32_t  getWCookie() const { return 0; }
 
 private:
   struct GPRs {
@@ -252,6 +253,7 @@ public:
   void  setR14(uint64_t value) { _registers.__r14 = value; }
   uint64_t  getR15() const { return _registers.__r15; }
   void  setR15(uint64_t value) { _registers.__r15 = value; }
+  uint64_t  getWCookie() const { return 0; }
 
 private:
   struct GPRs {
@@ -490,6 +492,7 @@ public:
   void  setSP(uint32_t value) { _registers.__r1 = value; }
   uint64_t  getIP() const

Re: start building clang alongside gcc on amd64

2017-04-17 Thread Jonathan Gray
On Mon, Apr 17, 2017 at 10:04:47AM +0200, Mark Kettenis wrote:
> > Date: Mon, 17 Apr 2017 09:26:53 +0200
> > From: Landry Breuil 
> > Content-Disposition: inline
> > List-Owner: 
> > X-Loop: tech@openbsd.org
> > Sender: owner-t...@openbsd.org
> > X-CNFS-Analysis: v=2.2 cv=eoad9chX c=1 sm=0 tr=0
> > a=A3duGc4wJ8K8BtNzzvyz4A==:117 a=A3duGc4wJ8K8BtNzzvyz4A==:17
> > a=kj9zAlcOel0A:10 a=AzvcPWV-tVgA:10 a=8jJFin-u_-39G7b8fh0A:9
> > a=CjuIK1q_8ugA:10
> > X-Virus-Scanned: by XS4ALL Virus Scanner
> > X-XS4ALL-Spam-Score: -0.6 () RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS,
> > UNPARSEABLE_RELAY
> > X-XS4ALL-Spam: NO
> > Envelope-To: mark.kette...@xs4all.nl
> > 
> > On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> > > After further discussion it Theo, here is a new version of the diff.
> > > It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> > > and BUILD_GCC4 variables and fixes installation of the c++ headers.
> > > 
> > > Index: gnu/lib/Makefile
> > > ===
> > > RCS file: /cvs/src/gnu/lib/Makefile,v
> > > retrieving revision 1.20
> > > diff -u -p -r1.20 Makefile
> > > --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> > > +++ gnu/lib/Makefile  16 Apr 2017 18:30:53 -
> > > @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
> > >  .if make(obj)
> > >  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
> > >  .else
> > > -.  if ${COMPILER_VERSION:L} == "gcc3"
> > > +.  if ${BUILD_GCC3:L} == "yes"
> > >  SUBDIR+=libobjc libstdc++
> > > -.  elif ${COMPILER_VERSION:L} == "gcc4"
> > > +.  endif
> > > +.  if ${BUILD_GCC4:L} == "gcc4"
> > 
> > Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?
> 
> Yes, well spotted.

The logic in Makefile.cross which uses CLANG_ARCH should be reordered to
match bsd.own.mk or it will set COMPILER_VERSION=clang for amd64 though
that could come later.

ok jsg@

> 
> Index: gnu/lib/Makefile
> ===
> RCS file: /cvs/src/gnu/lib/Makefile,v
> retrieving revision 1.20
> diff -u -p -r1.20 Makefile
> --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> +++ gnu/lib/Makefile  17 Apr 2017 07:45:13 -
> @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
>  .if make(obj)
>  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+=libobjc libstdc++
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "yes"
>  # XXX make sure we build libobjc & libstdc++-v3 from gcc4
>  SUBDIR+=../usr.bin/cc/libobjc
>  SUBDIR+=libstdc++-v3 libsupc++-v3
> Index: gnu/usr.bin/Makefile
> ===
> RCS file: /cvs/src/gnu/usr.bin/Makefile,v
> retrieving revision 1.58
> diff -u -p -r1.58 Makefile
> --- gnu/usr.bin/Makefile  20 Feb 2017 01:00:26 -  1.58
> +++ gnu/usr.bin/Makefile  16 Apr 2017 18:32:43 -
> @@ -6,11 +6,13 @@
>  .if make(obj)
>  SUBDIR+= cc clang gcc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+= gcc
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "yes"
>  SUBDIR+= cc
> -.  elif ${COMPILER_VERSION:L} == "clang"
> +.  endif
> +.  if ${BUILD_CLANG:L} == "yes"
>  SUBDIR+= clang
>  .  endif
>  .endif
> Index: gnu/usr.bin/clang/Makefile.inc
> ===
> RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
> retrieving revision 1.4
> diff -u -p -r1.4 Makefile.inc
> --- gnu/usr.bin/clang/Makefile.inc16 Feb 2017 02:08:42 -  1.4
> +++ gnu/usr.bin/clang/Makefile.inc27 Mar 2017 15:56:49 -
> @@ -2,6 +2,11 @@
>  
>  LLVM_SRCS?=  ${.CURDIR}/../../../llvm
>  
> +.if ${COMPILER_VERSION:L} != "clang"
> +CC=  clang
> +CXX= clang++
> +.endif
> +
>  BOOTSTRAP_CLANG?=no
>  .if ${BOOTSTRAP_CLANG} == "yes"
>  CC=  egcc
> Index: include/Makefile
> ===
> RCS file: /cvs/src/include/Makefile,v
> retrieving revision 1.218
> diff -u -p -r1.218 Makefile
> --- include/Makefile  12 Mar 2017 23:28:13 -  1.218
> +++ include/Makefile  16 Apr 2017 18:38:35 -
> @@ -42,13 +42,15 @@ RDIRS=../lib/libcurses ../lib/libedit \
>   ../usr.bin/lex ../gnu/lib/libreadline \
>   ../sys/arch/${MACHINE}
>  
> -.if ${COMPILER_VERSION:L} == "gcc3"
> +.if ${BUILD_GCC3:L} == "yes"
>  RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
>  PRDIRS+= ../gnu/lib/libstdc++
> -.elif ${COMPILER_VERSION:L} == "gcc4"
> +.endif
> +.if ${BUILD_GCC4:L} == "yes"
>  RDIRS+= ../gnu/usr.bin/cc/libobjc
>  PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
> -.elif ${COMPILER_VERSION:L} == "clang"
> 

Re: armv7/omap: introducing amdisplay(4) + nxptda(4)

2017-04-17 Thread Matthieu Herrb
xOn Sun, Apr 16, 2017 at 12:07:34AM -0400, Ian Sutton wrote:
> 
> The USB host controller on the am335x isn't EHCI compatible and is currently
> unsupported, the only direct interface with the board is via a com(4) ftdi
> serial port that doesn't provide a wskbd(4) device which Xorg demands. None
> of the config options that would seem to suggest allowing you to bypass this
> work, but removing the xf86-input-kbd object files does (?). I'm not sure 
> whether
> it's appropriate to fix this in xenocara or through something like comkbd(4).
> 

Hi,

While it's technically possible (and has been done in the past) to
attach other keyboard devices directly to Xorg, it's not the direction
we're heading to with the work done by mpi@ and ulf@ on input
devices.

you should definatly have something that hooks into wskbd(4). Look at
how various keyboard protocols are hooked into wskbd for various
architectures. And I believe keyboards are a bit easier to handle than
pointing devices.

-- 
Matthieu Herrb



Re: start building clang alongside gcc on amd64

2017-04-17 Thread Mark Kettenis
> Date: Mon, 17 Apr 2017 09:26:53 +0200
> From: Landry Breuil 
> Content-Disposition: inline
> List-Owner: 
> X-Loop: tech@openbsd.org
> Sender: owner-t...@openbsd.org
> X-CNFS-Analysis: v=2.2 cv=eoad9chX c=1 sm=0 tr=0
>   a=A3duGc4wJ8K8BtNzzvyz4A==:117 a=A3duGc4wJ8K8BtNzzvyz4A==:17
>   a=kj9zAlcOel0A:10 a=AzvcPWV-tVgA:10 a=8jJFin-u_-39G7b8fh0A:9
>   a=CjuIK1q_8ugA:10
> X-Virus-Scanned: by XS4ALL Virus Scanner
> X-XS4ALL-Spam-Score: -0.6 () RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS,
>   UNPARSEABLE_RELAY
> X-XS4ALL-Spam: NO
> Envelope-To: mark.kette...@xs4all.nl
> 
> On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> > After further discussion it Theo, here is a new version of the diff.
> > It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> > and BUILD_GCC4 variables and fixes installation of the c++ headers.
> > 
> > Index: gnu/lib/Makefile
> > ===
> > RCS file: /cvs/src/gnu/lib/Makefile,v
> > retrieving revision 1.20
> > diff -u -p -r1.20 Makefile
> > --- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
> > +++ gnu/lib/Makefile16 Apr 2017 18:30:53 -
> > @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
> >  .if make(obj)
> >  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
> >  .else
> > -.  if ${COMPILER_VERSION:L} == "gcc3"
> > +.  if ${BUILD_GCC3:L} == "yes"
> >  SUBDIR+=libobjc libstdc++
> > -.  elif ${COMPILER_VERSION:L} == "gcc4"
> > +.  endif
> > +.  if ${BUILD_GCC4:L} == "gcc4"
> 
> Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?

Yes, well spotted.

Index: gnu/lib/Makefile
===
RCS file: /cvs/src/gnu/lib/Makefile,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile
--- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
+++ gnu/lib/Makefile17 Apr 2017 07:45:13 -
@@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
 .if make(obj)
 SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=libobjc libstdc++
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 # XXX make sure we build libobjc & libstdc++-v3 from gcc4
 SUBDIR+=../usr.bin/cc/libobjc
 SUBDIR+=libstdc++-v3 libsupc++-v3
Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile16 Apr 2017 18:32:43 -
@@ -6,11 +6,13 @@
 .if make(obj)
 SUBDIR+=   cc clang gcc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=   gcc
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG:L} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: include/Makefile
===
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.218
diff -u -p -r1.218 Makefile
--- include/Makefile12 Mar 2017 23:28:13 -  1.218
+++ include/Makefile16 Apr 2017 18:38:35 -
@@ -42,13 +42,15 @@ RDIRS=  ../lib/libcurses ../lib/libedit \
../usr.bin/lex ../gnu/lib/libreadline \
../sys/arch/${MACHINE}
 
-.if ${COMPILER_VERSION:L} == "gcc3"
+.if ${BUILD_GCC3:L} == "yes"
 RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
 PRDIRS+= ../gnu/lib/libstdc++
-.elif ${COMPILER_VERSION:L} == "gcc4"
+.endif
+.if ${BUILD_GCC4:L} == "yes"
 RDIRS+= ../gnu/usr.bin/cc/libobjc
 PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
-.elif ${COMPILER_VERSION:L} == "clang"
+.endif
+.if ${BUILD_CLANG:L} == "yes"
 RDIRS+= ../lib/libcxxabi ../lib/libcxx
 .endif
 
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 16 Apr 2017 18:35:14 -
@@ -2,7 +2,12 @@
 
 .include 
 

Re: start building clang alongside gcc on amd64

2017-04-17 Thread Landry Breuil
On Mon, Apr 17, 2017 at 09:20:21AM +0200, Mark Kettenis wrote:
> After further discussion it Theo, here is a new version of the diff.
> It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
> and BUILD_GCC4 variables and fixes installation of the c++ headers.
> 
> Index: gnu/lib/Makefile
> ===
> RCS file: /cvs/src/gnu/lib/Makefile,v
> retrieving revision 1.20
> diff -u -p -r1.20 Makefile
> --- gnu/lib/Makefile  21 Jan 2017 12:40:49 -  1.20
> +++ gnu/lib/Makefile  16 Apr 2017 18:30:53 -
> @@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
>  .if make(obj)
>  SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
>  .else
> -.  if ${COMPILER_VERSION:L} == "gcc3"
> +.  if ${BUILD_GCC3:L} == "yes"
>  SUBDIR+=libobjc libstdc++
> -.  elif ${COMPILER_VERSION:L} == "gcc4"
> +.  endif
> +.  if ${BUILD_GCC4:L} == "gcc4"

Typo here ? Shouldnt this be .  if ${BUILD_GCC4:L} == "yes" ?



Re: start building clang alongside gcc on amd64

2017-04-17 Thread Mark Kettenis
After further discussion it Theo, here is a new version of the diff.
It explicitly lists the gcc4 architectures now, introduces BUILD_GCC3
and BUILD_GCC4 variables and fixes installation of the c++ headers.

After applying this diff you need to:

1. Run make install in /usr/src/share/mk

2. Bootstrap clang by running:

# pkg_add g++
# cd /usr/src/gnu/usr.bin/clang
# make obj
# make BOOTSTRAP_CLANG=yes
# make install

3. Build libcompiler_rt

# cd /usr/src/lib/libcompiler_rt
# make obj
# make depend
# make
# make install

4. Do a full build

These instructions may not be 100% accurate yet ;).


Index: gnu/lib/Makefile
===
RCS file: /cvs/src/gnu/lib/Makefile,v
retrieving revision 1.20
diff -u -p -r1.20 Makefile
--- gnu/lib/Makefile21 Jan 2017 12:40:49 -  1.20
+++ gnu/lib/Makefile16 Apr 2017 18:30:53 -
@@ -6,9 +6,10 @@ SUBDIR+=libiberty libreadline
 .if make(obj)
 SUBDIR+=libobjc libstdc++ libstdc++-v3 libsupc++-v3 ../usr.bin/cc/libobjc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=libobjc libstdc++
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "gcc4"
 # XXX make sure we build libobjc & libstdc++-v3 from gcc4
 SUBDIR+=../usr.bin/cc/libobjc
 SUBDIR+=libstdc++-v3 libsupc++-v3
Index: gnu/usr.bin/Makefile
===
RCS file: /cvs/src/gnu/usr.bin/Makefile,v
retrieving revision 1.58
diff -u -p -r1.58 Makefile
--- gnu/usr.bin/Makefile20 Feb 2017 01:00:26 -  1.58
+++ gnu/usr.bin/Makefile16 Apr 2017 18:32:43 -
@@ -6,11 +6,13 @@
 .if make(obj)
 SUBDIR+=   cc clang gcc
 .else
-.  if ${COMPILER_VERSION:L} == "gcc3"
+.  if ${BUILD_GCC3:L} == "yes"
 SUBDIR+=   gcc
-.  elif ${COMPILER_VERSION:L} == "gcc4"
+.  endif
+.  if ${BUILD_GCC4:L} == "yes"
 SUBDIR+=   cc
-.  elif ${COMPILER_VERSION:L} == "clang"
+.  endif
+.  if ${BUILD_CLANG:L} == "yes"
 SUBDIR+=   clang
 .  endif
 .endif
Index: gnu/usr.bin/clang/Makefile.inc
===
RCS file: /cvs/src/gnu/usr.bin/clang/Makefile.inc,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.inc
--- gnu/usr.bin/clang/Makefile.inc  16 Feb 2017 02:08:42 -  1.4
+++ gnu/usr.bin/clang/Makefile.inc  27 Mar 2017 15:56:49 -
@@ -2,6 +2,11 @@
 
 LLVM_SRCS?=${.CURDIR}/../../../llvm
 
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
 BOOTSTRAP_CLANG?=no
 .if ${BOOTSTRAP_CLANG} == "yes"
 CC=egcc
Index: include/Makefile
===
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.218
diff -u -p -r1.218 Makefile
--- include/Makefile12 Mar 2017 23:28:13 -  1.218
+++ include/Makefile16 Apr 2017 18:38:35 -
@@ -42,13 +42,15 @@ RDIRS=  ../lib/libcurses ../lib/libedit \
../usr.bin/lex ../gnu/lib/libreadline \
../sys/arch/${MACHINE}
 
-.if ${COMPILER_VERSION:L} == "gcc3"
+.if ${BUILD_GCC3:L} == "yes"
 RDIRS+= ../gnu/usr.bin/gcc ../gnu/lib/libobjc
 PRDIRS+= ../gnu/lib/libstdc++
-.elif ${COMPILER_VERSION:L} == "gcc4"
+.endif
+.if ${BUILD_GCC4:L} == "yes"
 RDIRS+= ../gnu/usr.bin/cc/libobjc
 PRDIRS+= ../gnu/lib/libstdc++-v3 ../gnu/usr.bin/cc/include
-.elif ${COMPILER_VERSION:L} == "clang"
+.endif
+.if ${BUILD_CLANG:L} == "yes"
 RDIRS+= ../lib/libcxxabi ../lib/libcxx
 .endif
 
Index: lib/libcompiler_rt/Makefile
===
RCS file: /cvs/src/lib/libcompiler_rt/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libcompiler_rt/Makefile 9 Apr 2017 21:47:05 -   1.6
+++ lib/libcompiler_rt/Makefile 16 Apr 2017 18:35:14 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG:L} == "yes"
 
 LIB=   compiler_rt
 NOPIC=
Index: lib/libcxx/Makefile
===
RCS file: /cvs/src/lib/libcxx/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- lib/libcxx/Makefile 16 Feb 2017 02:08:42 -  1.5
+++ lib/libcxx/Makefile 16 Apr 2017 18:35:26 -
@@ -2,7 +2,12 @@
 
 .include 
 
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${COMPILER_VERSION:L} != "clang"
+CC=clang
+CXX=   clang++
+.endif
+
+.if ${BUILD_CLANG:L} == "yes"
 
 HDRDIR=${.CURDIR}/include
 SRCDIR=${.CURDIR}/src
Index: lib/libcxxabi/Makefile
===
RCS file: /cvs/src/lib/libcxxabi/Makefile,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile
--- lib/libcxxabi/Makefile  6 Apr 2017 09:28:29 -   1.7
+++ lib/libcxxabi/Makefile  16 Apr 2017 18:35:39 -
@@ -2,7 +2,12 @@