andreas-kupries / critcl

Critcl lets you easily embed C code in Tcl. Online documentation at
http://andreas-kupries.github.io/critcl
Other
69 stars 19 forks source link

Build fails on macOS 10.14 (Mojave) #92

Open pozix604 opened 5 years ago

pozix604 commented 5 years ago

The build of Critcl using the standard instructions fails on macOS 10.14. It turns out the reason is that the detection of the SDK path does not work on new versions of macOS and Xcode. Defining the SDKROOT environment variable fixes the problem but the code should be fixed to automatically detect the SDK path.

Here is the failure:

andreas-kupries-critcl-0841990 $ /usr/local/opt/tcl-tk/bin/tclsh `pwd`/build.tcl install
Installing into:
    Packages:   /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6
    Application:    /usr/local/Cellar/tcl-tk/8.6.9/bin

Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-app3.1.17
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl3.1.17
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-bitmap1.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-class1.0.7
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-cutil0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-emap1.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-enum1.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-iassoc1.0.2
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-literals1.2
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-platform1.0.15
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-util1.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/dict841
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/lassign841.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/lmap841
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_container1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_decl1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_header1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_init1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_lib1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_macro1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_slot1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_genframe1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_reader1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_writer1
Installed application:  /usr/local/Cellar/tcl-tk/8.6.9/bin/critcl
expected version number but got ""
    while executing
"package vcompare $ver 10.4"
    ("foreach" body line 3)
    invoked from within
"foreach dir [glob -nocomplain -tails  -directory $base/SDKs MacOSX*] {
            set ver [string trimright  [file rootname [string range $dir $pos e..."
    invoked from within
"if {[string match macosx-* $platform]} {
    if {[info exists ::env(SDKROOT)] && $::env(SDKROOT) ne ""} {
        set SDKROOT $::env(SDKROOT)
    } el..."
    invoked from within
"interp eval $run $line"
    (procedure "readconfig" line 84)
    invoked from within
"readconfig [file join $mydir Config]"
    (procedure "::critcl::Initialize" line 39)
    invoked from within
"::critcl::Initialize"
    (file "/usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl3.1.17/critcl.tcl" line 5924)
    invoked from within
"source /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl3.1.17/critcl.tcl"
    ("package ifneeded critcl 3.1.17" script)
    invoked from within
"package require critcl"
    (file "/usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-app3.1.17/critcl.tcl" line 22)
    invoked from within
"source /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-app3.1.17/critcl.tcl"
    ("package ifneeded critcl::app 3.1.17" script)
    invoked from within
"package require critcl::app"
    (file "/usr/local/Cellar/tcl-tk/8.6.9/bin/critcl" line 9)
child process exited abnormally
    while executing
"exec >@ stdout 2>@ stderr /usr/local/Cellar/tcl-tk/8.6.9/bin/critcl -libdir /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/tmp -pkg /Users/first/Downloads/..."
    ("eval" body line 1)
    invoked from within
"eval $cmd"
    invoked from within
"_install"
    ("eval" body line 1)
    invoked from within
"eval _$argv"

Here is the new way to identify the SDK path:

$ xcrun --sdk macosx --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

And here it is working after defining the SDKROOT variable. Ideally, the build script would automatically run the above command, get the right path and build correctly.

andreas-kupries-critcl-0841990 $ export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
andreas-kupries-critcl-0841990 $ /usr/local/opt/tcl-tk/bin/tclsh `pwd`/build.tcl install
Installing into:
    Packages:   /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6
    Application:    /usr/local/Cellar/tcl-tk/8.6.9/bin

Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-app3.1.17
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl3.1.17
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-bitmap1.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-class1.0.7
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-cutil0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-emap1.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-enum1.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-iassoc1.0.2
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-literals1.2
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-platform1.0.15
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl-util1.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/dict841
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/lassign841.0.1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/lmap841
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_container1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_decl1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_header1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_init1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_lib1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_macro1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_gen_slot1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_genframe1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_reader1
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/stubs_writer1
Installed application:  /usr/local/Cellar/tcl-tk/8.6.9/bin/critcl
Config:   macosx-x86_64
Build:    macosx-x86_64-gcc
Target:   macosx-x86_64
Source:   md5c.tcl  (provide critcl_md5c 0.12)
Library:  md5c.dylib
 (tclStubsPtr     =>  TclStubs *tclStubsPtr;)
 (tclPlatStubsPtr =>  TclPlatStubs *tclPlatStubsPtr;)
Package:  /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/tmp/md5c
Installed package:      /usr/local/Cellar/tcl-tk/8.6.9/lib/tcl8.6/critcl_md5c0.12
andreas-kupries commented 4 years ago

Does the xcrun --sdk macosx --show-sdk-path work before Mojave as well ? If yes, how far back ? Would it make sense to simply try it when SDKROOT is missing ?

andreas-kupries commented 4 years ago

Some more information. Your error stack contains

expected version number but got ""
    while executing
"package vcompare $ver 10.4"

indicated that the variable ver contains the empty string.

The code I am looking at however (https://github.com/andreas-kupries/critcl/blob/master/lib/critcl/Config#L97) checks for the empty string and prevent the vcompare from being run in that case.

Ah! That was issue #84, and the change is not in a release yet. What happens on your system when you put that change in ?

Right now I suspect that while the stack trace goes away SDKROOT still has to be set manually to make it work. Not sure, I do not have a Mojave system to test with.

juster commented 1 week ago

I did not have this issue with Mac OS 14.6 but I have been tinkering with the Config in order to use Apple Silicon (arm64) compilation.

Does the xcrun --sdk macosx --show-sdk-path work before Mojave as well ? If yes, how far back ?

This Technical Note (TN2339) from Apple says that xcrun has been available since 10.9:

https://developer.apple.com/library/archive/technotes/tn2339/_index.html

The 10.9 release was codenamed Mavericks and released in 2013.

Would it make sense to simply try it when SDKROOT is missing ?

Yes it looks that way.