[RFC,0/6] A different approach to startup-with-shell on macOS

Message ID 20180926111130.18956-1-tom@tromey.com
Headers show
Series
  • A different approach to startup-with-shell on macOS
Related show

Message

Tom Tromey Sept. 26, 2018, 11:11 a.m.
Currently the macOS port will disable startup-with-shell on versions
of macOS that have System Integrity Protection.  This is done because
with SIP, gdb cannot ptrace certain executables, including the normal
shells.

This series implements a different approach: copy the user's shell
executable to the cache directory and arrange to use the copy.  This
avoids the SIP restrictions.

Most of the series is just cleanup, rearranging so some private
functions can be shared, and fixing a few small things I noticed along
the way.

This has been regression tested by one of the buildbot builders, and
then I tested the final patch on macOS High Sierra.

One question I have is whether it's possible to build gdb on an older
version of macOS and then run it on a newer version.  If this can be
done, then the #if-based approach taken in the final patch will not
work.

I didn't include any way to control this feature other than "set
startup-with-shell off".  My thinking was that turning this off will
just result in failures, which isn't useful.  However if there's a
reason to do something else, I could add it.

Tom

Comments

Simon Marchi Sept. 28, 2018, 9:21 p.m. | #1
On 2018-09-26 07:11, Tom Tromey wrote:
> One question I have is whether it's possible to build gdb on an older

> version of macOS and then run it on a newer version.  If this can be

> done, then the #if-based approach taken in the final patch will not

> work.


Good question.  I asked on #machomebrew about how they build the binary 
packages, whether a package intended for a certain macOS version is 
always built on that version of macOS, or there is some cross-version 
compiling involved.

Until we have proof that it's necessary, I think what you have done is 
fine.

> I didn't include any way to control this feature other than "set

> startup-with-shell off".  My thinking was that turning this off will

> just result in failures, which isn't useful.  However if there's a

> reason to do something else, I could add it.


Makes sense.

Simon
Pedro Alves Sept. 29, 2018, 6:43 p.m. | #2
On 09/26/2018 12:11 PM, Tom Tromey wrote:

> One question I have is whether it's possible to build gdb on an older

> version of macOS and then run it on a newer version.  If this can be

> done, then the #if-based approach taken in the final patch will not

> work.


I'd suspect so.  What, e.g., does Homebrew do?  Do they have packages
built once for every Darwin version, or a single binary for several
Darwin versions?  I'd think the latter, but I don't really know.
And if indeed the latter, do they always build on the newest
Darwin, or perhaps the oldest?

Thanks,
Pedro Alves
Simon Marchi Sept. 29, 2018, 7:50 p.m. | #3
On 2018-09-29 14:43, Pedro Alves wrote:
> On 09/26/2018 12:11 PM, Tom Tromey wrote:

> 

>> One question I have is whether it's possible to build gdb on an older

>> version of macOS and then run it on a newer version.  If this can be

>> done, then the #if-based approach taken in the final patch will not

>> work.

> 

> I'd suspect so.  What, e.g., does Homebrew do?  Do they have packages

> built once for every Darwin version, or a single binary for several

> Darwin versions?  I'd think the latter, but I don't really know.

> And if indeed the latter, do they always build on the newest

> Darwin, or perhaps the oldest?


Here's the answer I got on the homebrew IRC channel:

> homebrew generally does this (but i think it's probably more 

> conservative than it needs to be)

> a bottle should never be deployed to an older macos version than it was 

> built on, anyway


"this" refers to whether the binaries always run on the same macos 
version as the one on which they have been built.

Simon
Pedro Alves Sept. 29, 2018, 8:38 p.m. | #4
On 09/29/2018 08:50 PM, Simon Marchi wrote:
> On 2018-09-29 14:43, Pedro Alves wrote:

>> On 09/26/2018 12:11 PM, Tom Tromey wrote:

>>

>>> One question I have is whether it's possible to build gdb on an older

>>> version of macOS and then run it on a newer version.  If this can be

>>> done, then the #if-based approach taken in the final patch will not

>>> work.

>>

>> I'd suspect so.  What, e.g., does Homebrew do?  Do they have packages

>> built once for every Darwin version, or a single binary for several

>> Darwin versions?  I'd think the latter, but I don't really know.

>> And if indeed the latter, do they always build on the newest

>> Darwin, or perhaps the oldest?

> 

> Here's the answer I got on the homebrew IRC channel:

> 

>> homebrew generally does this (but i think it's probably more conservative than it needs to be)

>> a bottle should never be deployed to an older macos version than it was built on, anyway

> 

> "this" refers to whether the binaries always run on the same macos version as the one on which they have been built.


Great, that clears it up.

Thanks,
Pedro Alves
Tom Tromey Oct. 1, 2018, 9:12 a.m. | #5
>> "this" refers to whether the binaries always run on the same macos

>> version as the one on which they have been built.


Pedro> Great, that clears it up.

Homebrew doesn't need it, which I think means the current approach is
good enough for Homebrew users.  But I don't know if this is something
that should be handled by gdb anyway.  Maybe coding the constant into
gdb and doing this unconditionally is better?

Tom