Skip to content

Commit

Permalink
Allow running under Rosetta 2 if build_arch=x86_64
Browse files Browse the repository at this point in the history
This allows users who explicitly request it by setting build_arch in
macports.conf to have a fully x86_64 build environment.
  • Loading branch information
jmroot committed Oct 15, 2024
1 parent 2fa2e91 commit 425b158
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/macports1.0/macports.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,14 +1069,6 @@ proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
}
}

# Check that the current platform is the one we were configured for, otherwise need to do migration
set skip_migration_check [expr {[info exists macports::global_options(ports_no_migration_check)] && $macports::global_options(ports_no_migration_check)}]
if {!$skip_migration_check && [migrate::needs_migration migrate_reason]} {
ui_error $migrate_reason
ui_error "Please run 'sudo port migrate' or follow the migration instructions: https://trac.macports.org/wiki/Migration"
return -code error "OS platform mismatch"
}

# Ensure that the macports user directory (i.e. ~/.macports) exists if HOME is defined.
# Also save $HOME for later use before replacing it with our own.
if {[info exists env(HOME)]} {
Expand Down Expand Up @@ -1614,6 +1606,14 @@ match macports.conf.default."
set build_arch [lindex $build_arch 0]
}

# Check that the current platform is the one we were configured for, otherwise need to do migration
set skip_migration_check [expr {[info exists macports::global_options(ports_no_migration_check)] && $macports::global_options(ports_no_migration_check)}]
if {!$skip_migration_check && [migrate::needs_migration migrate_reason]} {
ui_error $migrate_reason
ui_error "Please run 'sudo port migrate' or follow the migration instructions: https://trac.macports.org/wiki/Migration"
return -code error "OS platform mismatch"
}

if {![info exists macosx_deployment_target]} {
if {[vercmp $macos_version 11] >= 0} {
set macosx_deployment_target ${macos_version_major}.0
Expand Down
4 changes: 2 additions & 2 deletions src/macports1.0/migrate.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace eval migrate {
#
# @return true iff the migration procedure is needed
proc needs_migration {{reasonvar {}}} {
global macports::os_platform macports::os_major
global macports::os_platform macports::os_major macports::build_arch
if {$reasonvar ne {}} {
upvar $reasonvar reason
set reason {}
Expand All @@ -245,7 +245,7 @@ namespace eval migrate {
set reason "Current platform \"$os_platform $os_major\" does not match expected platform \"$macports::autoconf::os_platform $macports::autoconf::os_major\""
return 1
}
if {$os_platform eq "darwin" && $os_major >= 20
if {$os_platform eq "darwin" && $os_major >= 20 && $build_arch ne "x86_64"
&& ![catch {sysctl sysctl.proc_translated} translated] && $translated
} then {
# Check if our tclsh has an arm64 slice - rebuilding not needed if it's universal
Expand Down
3 changes: 2 additions & 1 deletion src/macports1.0/selfupdate.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ proc selfupdate::verify_signature_legacy {path signature_path} {
# @param source Path to the source code to be installed.
proc selfupdate::install {source} {
global \
macports::build_arch \
macports::developer_dir \
macports::macos_version_major \
macports::os_major \
Expand Down Expand Up @@ -489,7 +490,7 @@ proc selfupdate::install {source} {
}
}
}
if {$os_major >= 20 && ![catch {sysctl sysctl.proc_translated} translated] && $translated} {
if {$os_major >= 20 && $build_arch ne "x86_64" && ![catch {sysctl sysctl.proc_translated} translated] && $translated} {
# Force a native build
set arch_arg "/usr/bin/arch -arm64 /usr/bin/env "
}
Expand Down

0 comments on commit 425b158

Please sign in to comment.