tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Disabling strip by default on Darwin [Re: Fix Erlang on OSX]



* On 2015-08-31 at 05:33 BST, Steven Williamson wrote:

> > > Is this the correct fix though ? arguably it looks like on OSX strip by
> > > default attempts to strip too many symbols, should binaries be stripped
> > > at all on install by default ?
> >
> > Yes possibly, I set INSTALL_UNSTRIPPED=yes by default on our SmartOS
> > builds but not on OSX.  I will test a full bulk build with strip
> > disabled to see how many extra packages we get before deciding whether
> > it should be disabled by default.
>
> I had been speaking to Greg Troxel about this, as I mentioned it might be
> fixable by changing the flags used when strip is called.
> 
> The root cause of the issue appears to be that OSX strip behaves
> differently to strip on most other OS's.
> 
> Calling strip on a binary on OSX with no other arguments attempts to strip
> all symbols by default. This then leads to an error return code and output
> to stdout about relocatable symbols that can not be stripped. OSX strip
> will with default options attempt to strip everything but will always
> refuse to strip relocatable symbols and reports these as an error.
> 
> The result is any object file with relocatable symbols will error on
> install with the OSX defaults.
> 
> If strip is run with the `-u` and `-r` flags on OSX, keep global and
> relocatable symbols, the strip command runs fine and just strips local
> symbols.
> 
> Strip however is never called directly, so there is no easy way to supply
> the flags. Instead the -s option is passed to `install`, and `install`
> execs strip when installing the file.
> 
> Looking at pkgsrc, implementing a wrapper for strip might be a solution so
> we can fudge the correct flags when strip is called on OSX ? Im unfamiliar
> with the internals of pkgsrc so unsure if that is the purpose of wrappers
> of if this is ultimately a good solution.

I don't think this is going to work.  Darwin /usr/bin/install uses the
xcode selection method to find the strip(1) program, e.g.:

  $ type strip
  strip is /Users/jperkin/bin/strip

  $ install -s jsstyle /tmp
  /Library/Developer/CommandLineTools/usr/bin/strip: can't process non-object and non-archive file: /private/tmp/jsstyle

  $ env DEVELOPER_DIR=$HOME/bin install -s jsstyle /tmp
  xcrun: error: invalid DEVELOPER_DIR path (/Users/jperkin/bin), missing xcrun at: /Users/jperkin/bin/usr/bin/xcrun

so even if we create a strip tool, I'm not sure we can ensure install(1) finds
it before the native one.  We'd have to go with sysutils/bsdinstall and patch
it to use an alternative strip, and I'm not sure it's worth the effort.

> Personally I would vote that the default on OSX is changed to
> INSTALL_UNSTRIPPED. As the symbols are useful for debugging anyway,
> packages won't hit this issue in the future, and this is simpler than
> implementing a wrapper.

Yes, this is by far my preferred fix too, being of the opinion that stripping
is actively harmful and a relic of the era of 20MB disks.

My proposed fix would simply be:

  --- mk/platform/Darwin.mk	17 Aug 2015 17:35:23 -0000	1.69
  +++ mk/platform/Darwin.mk	31 Aug 2015 09:32:18 -0000
  @@ -144,3 +144,3 @@
   _STRIPFLAG_CC?=		${_INSTALL_UNSTRIPPED:D:U-Wl,-x} # cc(1) option to strip
  -_STRIPFLAG_INSTALL?=	${_INSTALL_UNSTRIPPED:D:U-s}	# install(1) option to strip
  +_STRIPFLAG_INSTALL?=	${_INSTALL_UNSTRIPPED:D:U}	# install(1) option to strip
  
Any strong objections to this?  We already do this on other platforms (HPUX,
OSF1, SCO, UnixWare).

Cheers,

-- 
Jonathan Perkin  -  Joyent, Inc.  -  www.joyent.com


Home | Main Index | Thread Index | Old Index