Bug 216065 - sysutils/lsof - fix build on FreeBSD11/ARM
Summary: sysutils/lsof - fix build on FreeBSD11/ARM
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: Larry Rosenman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-14 14:49 UTC by Oleksii Samorukov
Modified: 2017-01-15 15:35 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (ler)


Attachments
patch to compile lsof on fbsd/arm (742 bytes, patch)
2017-01-14 14:49 UTC, Oleksii Samorukov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksii Samorukov freebsd_committer 2017-01-14 14:49:53 UTC
Created attachment 178884 [details]
patch to compile lsof on fbsd/arm

On the FreeBSD ARM port port is not working. During compilation i see 

In file included from /usr/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h:41:
In file included from /usr/src/sys/cddl/compat/opensolaris/sys/debug.h:33:
In file included from /usr/src/sys/cddl/compat/opensolaris/sys/systm.h:35:
In file included from /usr/include/sys/systm.h:41:
In file included from /usr/include/machine/atomic.h:48:
/usr/include/machine/cpuconf.h:119:2: error: ARM_NARCH is 0
#error ARM_NARCH is 0
 ^
/usr/include/machine/cpuconf.h:174:2: error: ARM_NMMUS is 0
#error ARM_NMMUS is 0

and compilation fails. After quick checking of the cpuconf.h i found a workaround for this - it is possible to define KLD_MODULE to avoid this useless check. After this change lsof compiled successfully and works as expected.
Comment 1 Larry Rosenman freebsd_committer 2017-01-14 15:03:47 UTC
testing patch.
Comment 2 Larry Rosenman freebsd_committer 2017-01-14 15:52:36 UTC
test builds are fine, waiting on my mentor to commit it.
Comment 3 Adam Weinberger freebsd_committer 2017-01-14 17:50:28 UTC
lsof is not a kernel module though. Something else probably needs to be included before machine/cpuconf.h that sets up the defines that are being added to get those ARM_NARCH and ARM_NMMUS #defines.
Comment 4 Larry Rosenman freebsd_committer 2017-01-14 18:19:49 UTC
Arm folks?
Comment 5 Oleksii Samorukov freebsd_committer 2017-01-14 19:06:17 UTC
Its not a kernel module but it is emulates kernel source in a hacky way to get some structures normally available for the kernel source only and not exported to the userland. So this patch is correct, because this structures are still there but ARM CPU type is not tested.
Comment 6 Adam Weinberger freebsd_committer 2017-01-14 19:33:47 UTC
Fair enough. That works for me. Thanks for the explanation.
Comment 7 commit-hook freebsd_committer 2017-01-14 19:37:57 UTC
A commit references this bug:

Author: ler
Date: Sat Jan 14 19:36:59 UTC 2017
New revision: 431492
URL: https://svnweb.freebsd.org/changeset/ports/431492

Log:
  Fix sysutils/lsof on arm.

  This fixes the case where ARM_NARCH and ARM_NMMUS are 0, since the lsof(1) sources get hacky
  access to kernel structures.

  PR:     216065
  Submitted by: samm os2 kiev ua
  Approved by:    adamw (mentor)
  Differential Revision:  https://reviews.freebsd.org/D9176

Changes:
  head/sysutils/lsof/Makefile
  head/sysutils/lsof/files/patch-dialects_freebsd_dlsof.h
  head/sysutils/lsof/files/patch-dialects_freebsd_dnode2.c
Comment 8 Larry Rosenman freebsd_committer 2017-01-14 19:39:12 UTC
Committed, thanks.
Comment 9 Mikael Urankar freebsd_committer 2017-01-15 09:30:51 UTC
ARM_NARCH and ARM_NMMUS are 0 because clang defines __ARM_ARCH_6KZ__ since clang3.8 iirc.

6ZK is a mispelling of 6KZ:
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01679.html


--- machine/cpuconf.h.orig      2016-10-30 08:51:47.573780000 +0100
+++ machine/cpuconf.h   2017-01-15 10:24:16.140092000 +0100
@@ -108,7 +108,7 @@
 #define ARM_ARCH_4 1
 #define ARM_NARCH  1
 #define CPU_ARM9 1
-#elif defined(__ARM_ARCH_6ZK__)
+#elif defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6KZ__)
 #undef  ARM_ARCH_6
 #undef  ARM_NARCH
 #define ARM_ARCH_6 1
Comment 10 Larry Rosenman freebsd_committer 2017-01-15 09:38:24 UTC
Can you file a bug against the base system for that patch, please?
Comment 11 commit-hook freebsd_committer 2017-01-15 15:35:16 UTC
A commit references this bug:

Author: ler
Date: Sun Jan 15 15:34:43 UTC 2017
New revision: 431585
URL: https://svnweb.freebsd.org/changeset/ports/431585

Log:
  MFH: r431492 r431583

  Fix sysutils/lsof on arm.

  This fixes the case where ARM_NARCH and ARM_NMMUS are 0, since the lsof(1) sources get hacky
  access to kernel structures.

  PR:     216065
  Submitted by: samm os2 kiev ua
  Obtained from:	Vic Abell (author)

  Approved by:	ports-secteam (blanket), adamw (mentor)

Changes:
_U  branches/2017Q1/
  branches/2017Q1/sysutils/lsof/Makefile
  branches/2017Q1/sysutils/lsof/distinfo