Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#61899 closed defect (fixed)

ruby27 @2.7.2: pre-built archive for Big Sur contains hardcoded path to 11.0 SDK

Reported by: michaellass (Michael Lass) Owned by: kimuraw (kimura wataru)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: ruby27

Description

When ruby27 is installed from the pre-built archive (https://packages.macports.org/ruby27/ruby27-2.7.2_0.darwin_20.x86_64.tbz2), there are two files included with hardcoded paths to the 11.0 SDK:

  • /opt/local/lib/ruby2.7/2.7.0/x86_64-darwin20/rbconfig.rb
  • /opt/local/lib/pkgconfig/ruby-2.7.pc

The entries in the first file (rbconfig.rb) cause gem to fail building native extensions on macOS 11.1:

Building native extensions. This could take a while...
ERROR:  Error installing iStats:
	ERROR: Failed to build gem native extension.

    current directory: /Users/lass/.gem/ruby/gems/iStats-1.6.1/ext/osx_stats
/opt/local/bin/ruby2.7 -I /opt/local/lib/ruby2.7/2.7.0 -r ./siteconf20201223-83991-j5zrwi.rb extconf.rb
creating Makefile

current directory: /Users/lass/.gem/ruby/gems/iStats-1.6.1/ext/osx_stats
make "DESTDIR=" clean

current directory: /Users/lass/.gem/ruby/gems/iStats-1.6.1/ext/osx_stats
make "DESTDIR="
compiling smc.c
clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk' [-Wmissing-sysroot]
smc.c:20:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
make: *** [smc.o] Error 1

make failed, exit code 2

Either changing the files manually from 11.0 to 11.1 or building ruby27 from source fixes the issue.

I'm not sure how this could be fixed properly to work on 11.0 and 11.1. Maybe it is possible to specify /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk as SDK in the portfile such that this more universal symlink is stored in those files instead.

Change History (8)

comment:1 Changed 3 years ago by jmroot (Joshua Root)

Cc: kimuraw removed
Owner: set to kimuraw
Status: newassigned

The approach used by python is to detect at runtime when an -isysroot flag points to an SDK that doesn't exist, and remove it. Until and unless the ruby project wants to implement something similar, it may be best to simply delete all -isysroot flags from rbconfig.rb. That will result in the default SDK being used when one is not specified, but will still follow one specified in the environment if present. The .pc file should not contain any flags specifying an SDK in any case.

comment:2 Changed 3 years ago by kencu (Ken)

and the perls are broken too...

comment:3 Changed 3 years ago by kimuraw (kimura wataru)

Status: assignedaccepted

comment:4 Changed 3 years ago by michaellass (Michael Lass)

I just noticed that gcc10 (and maybe other compilers) suffer from similar problems as well, looking for the 11.0 SDK when installed from a binary archive. There is still a bug report open from the last time this happened: https://trac.macports.org/ticket/59665

The workaround is similar to the one for ruby27: port upgrade -s -n --force gcc10

comment:5 Changed 3 years ago by kimuraw (kimura wataru)

Resolution: fixed
Status: acceptedclosed

In 06938beeea8a135d46a9577d775b27d877058c1c/macports-ports (master):

lang/ruby27, ruby26: fix build error of ruby extentions on macOS 11

macOS 11 and Xcode 12 changes SDK path for macOS minor versions.
this breaks building ruby binary extentions.

/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk

-> /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk (11.0 removed)


To fix this problem, port:ruby2x rewrites SDKROOT to "MacOSX.sdk" (symlink)
from "MacOSX11.x.sdk" in rbconfig.rb and ruby-2.x.pc at post-build.

Closes: #61827
Closes: #61899

comment:6 Changed 3 years ago by kimuraw (kimura wataru)

In 20e9f727c705381eb6694717f1cc14ad9945eaa3/macports-ports (master):

lang/ruby30, ruby27, ruby26: fix target OS versions of sdkroot hack

target OS versions: darwin 20 (macOS 11) *or later*

rewrite sdkroot in rbconfig.rb and ruby-*.pc to MacOSX.sdk from MacOS11.x.sdk.
see #61899

comment:7 Changed 3 years ago by kimuraw (kimura wataru)

In c8d2262437141217990aa396fd1c98219915be43/macports-ports (master):

lang/ruby25 .. ruby20, ruby19: fix build error of ruby extentions on macOS 11

  • rewrite sdkroot in rbconfig.rb and ruby-*.pc to MacOSX.sdk from MacOS11.x.sdk see #61899
  • fix ruby19 build error of ext/openssl

comment:8 Changed 3 years ago by kimuraw (kimura wataru)

In 12aec60fe1cd54e3bd6f9c10b2eaab79f89bd9c4/macports-ports (master):

lang/ruby: apply sdkroot hack on macOS 11

rewrite sdkroot in rbconfig.rb to MacOSX.sdk from MacOS11.x.sdk
(ruby-1.8 does not contain .pc for pkg-config)

#61899

Note: See TracTickets for help on using tickets.