Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Terra on macOS Movaje #435

Merged
merged 30 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1a66ca6
Update Travis to macOS 10.14 Mojave.
elliottslaughter Apr 18, 2020
c3badbc
Downgrade XCode to 10.3.
elliottslaughter Apr 18, 2020
5363d0a
Workaround macOS package issue.
elliottslaughter Apr 18, 2020
266b3fc
Try a different XCode version.
elliottslaughter Apr 18, 2020
60f8f71
Try a different type of workaround.
elliottslaughter Apr 18, 2020
cefdfa3
Try xcode-select --install.
elliottslaughter Apr 18, 2020
ef19e43
Try using the command line tools SDK path.
elliottslaughter Apr 18, 2020
a216cbf
Try bumping XCode version again.
elliottslaughter Apr 18, 2020
2e162aa
Workaround for https://github.com/LuaJIT/LuaJIT/issues/575.
elliottslaughter Apr 21, 2020
d75cc60
Try brew versions of LLVM builds, in the hopes that they fix sysroot …
elliottslaughter Apr 21, 2020
d3e5841
Go back to old include path.
elliottslaughter Apr 21, 2020
f217a96
Fix typo.
elliottslaughter Apr 21, 2020
c049d01
Wait, we shouldn't need any INCLUDE_PATH hack...
elliottslaughter Apr 21, 2020
b9240c4
Try higher deployment target.
elliottslaughter Apr 21, 2020
e63f3df
Try setting explicit path to CC/CXX.
elliottslaughter Apr 21, 2020
d568a2d
Try to really force CMake to use MY compiler.
elliottslaughter Apr 21, 2020
24da0f1
Put the INCLUDE_PATH back.
elliottslaughter Apr 21, 2020
7f13327
Get ctest output on failure.
elliottslaughter Apr 21, 2020
5f3054a
Fix test include path.
elliottslaughter Apr 21, 2020
9d8ff1b
Refactor macOS hack.
elliottslaughter Apr 21, 2020
2e5d1a6
Cast objc_msgSend to work around header type.
elliottslaughter Apr 21, 2020
8569f76
Revert "Fix typo."
elliottslaughter Apr 22, 2020
760f0f5
Revert "Try brew versions of LLVM builds, in the hopes that they fix …
elliottslaughter Apr 22, 2020
b6e434f
Revert "Try higher deployment target."
elliottslaughter Apr 22, 2020
8a5a17f
Cleanup.
elliottslaughter Apr 22, 2020
bf0b4d6
Avoid spew.
elliottslaughter Apr 22, 2020
70354f7
Fiddle with macOS test matrix.
elliottslaughter Apr 22, 2020
30ca3ed
Avoid modifying INCLUDE_PATH if /usr/include still exists, to avoid s…
elliottslaughter Apr 22, 2020
c589806
Try alternative to CMake CC workaround.
elliottslaughter Apr 22, 2020
3ede6d0
Revert "Try alternative to CMake CC workaround."
elliottslaughter Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: cpp
sudo: required
dist: xenial
osx_image: xcode10.1 # macOS 10.13
os:
- linux
- osx
compiler:
- gcc
- clang
Expand Down Expand Up @@ -39,20 +37,32 @@ jobs:
env: DOCKER_BUILD=ubuntu-18.04
- os: linux
env: DOCKER_BUILD=ubuntu-19.10
exclude:
# Various macOS tests seem to be broken.

# macOS tests
- os: osx
compiler: gcc
osx_image: xcode10.1 # macOS 10.13
compiler: clang
env: LLVM_CONFIG=llvm-config-3.5 CLANG=clang-3.5
- os: osx
env: LLVM_CONFIG=llvm-config-5.0 CLANG=clang-5.0 USE_CMAKE=1
osx_image: xcode10.1 # macOS 10.13
compiler: clang
env: LLVM_CONFIG=llvm-config-3.8 CLANG=clang-3.8
- os: osx
env: LLVM_CONFIG=llvm-config-6.0 CLANG=clang-6.0 USE_CMAKE=1 STATIC_LLVM=0 STATIC_LUAJIT=0
osx_image: xcode11.3 # macOS 10.14
compiler: clang
env: LLVM_CONFIG=llvm-config-6.0 CLANG=clang-6.0 USE_CMAKE=1
- os: osx
env: LLVM_CONFIG=llvm-config-8 CLANG=clang-8
osx_image: xcode11.3 # macOS 10.14
compiler: clang
env: LLVM_CONFIG=llvm-config-7 CLANG=clang-7 USE_CMAKE=1
- os: osx
env: LLVM_CONFIG=llvm-config-9 CLANG=clang-9
osx_image: xcode11.3 # macOS 10.14
compiler: clang
env: LLVM_CONFIG=llvm-config-8 CLANG=clang-8 USE_CMAKE=1
- os: osx
env: LLVM_CONFIG=llvm-config-9 CLANG=clang-9 USE_CMAKE=1 STATIC_LLVM=0 STATIC_LUAJIT=0
osx_image: xcode11.3 # macOS 10.14
compiler: clang
env: LLVM_CONFIG=llvm-config-9 CLANG=clang-9 USE_CMAKE=1

script:
- ./travis.sh
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ endif
build/lib/libluajit-5.1.a: build/$(LUAJIT_TAR)
(cd build; tar -xf $(LUAJIT_TAR))
# MACOSX_DEPLOYMENT_TARGET is a workaround for https://github.com/LuaJIT/LuaJIT/issues/484
(cd $(LUAJIT_DIR); $(MAKE) install PREFIX=$(realpath build) CC=$(CC) STATIC_CC="$(CC) -fPIC" MACOSX_DEPLOYMENT_TARGET=10.6)
# see also https://github.com/LuaJIT/LuaJIT/issues/575
(cd $(LUAJIT_DIR); $(MAKE) install PREFIX=$(realpath build) CC=$(CC) STATIC_CC="$(CC) -fPIC" MACOSX_DEPLOYMENT_TARGET=10.7)

release/include/terra/%.h: $(LUAJIT_INCLUDE)/%.h $(LUAJIT_LIB)
cp $(LUAJIT_INCLUDE)/$*.h $@
Expand Down
3 changes: 2 additions & 1 deletion cmake/Modules/GetLuaJIT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ else()
OUTPUT ${LUAJIT_STATIC_LIBRARY} ${LUAJIT_SHARED_LIBRARY_PATHS} ${LUAJIT_EXECUTABLE} ${LUAJIT_INSTALL_HEADERS}
DEPENDS ${LUAJIT_SOURCE_DIR}
# MACOSX_DEPLOYMENT_TARGET is a workaround for https://github.com/LuaJIT/LuaJIT/issues/484
COMMAND make install "PREFIX=${LUAJIT_INSTALL_PREFIX}" "CC=${CMAKE_C_COMPILER}" "STATIC_CC=${CMAKE_C_COMPILER} -fPIC" MACOSX_DEPLOYMENT_TARGET=10.6
# see also https://github.com/LuaJIT/LuaJIT/issues/575
COMMAND make install "PREFIX=${LUAJIT_INSTALL_PREFIX}" "CC=${CMAKE_C_COMPILER}" "STATIC_CC=${CMAKE_C_COMPILER} -fPIC" MACOSX_DEPLOYMENT_TARGET=10.7
WORKING_DIRECTORY ${LUAJIT_SOURCE_DIR}
VERBATIM
)
Expand Down
2 changes: 1 addition & 1 deletion tests/dynlib.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local ffi = require 'ffi'
-- test that the dynamic library for terra was built correctly
-- by compiling a new program that links against it and running it
terralib.includepath = terralib.terrahome.."/include/terra"
terralib.includepath = terralib.includepath .. ";" .. terralib.terrahome .. "/include/terra"
C = terralib.includecstring [[
#include <stdio.h>
#include "terra.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/exportdynamic.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terralib.includepath = terralib.terrahome.."/include/terra"
terralib.includepath = terralib.includepath .. ";" .. terralib.terrahome .. "/include/terra"
C = terralib.includecstring [[
#include "lua.h"
#include "lauxlib.h"
Expand Down
7 changes: 6 additions & 1 deletion tests/lib/objc.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ local mangleSelector
--replace methods such as: myobj:methodcall(arg0,arg1)
--with calls to the objc runtime api: objc_msgSend(&obj,sel_registerName("methodcall"),arg0,arg1)

-- Hack: As of macOS 10.15 this type signature has changed, see:
-- https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html
local objc_msgSend_type = terralib.types.funcpointer(
{&C.objc_object, &C.objc_selector}, &C.objc_object, true)

local struct Wrapper {
data : &C.objc_object
}
Wrapper.metamethods.__methodmissing = macro(function(sel,obj,...)
local arguments = {...}
sel = mangleSelector(sel,#arguments)
return `Wrapper { C.objc_msgSend(obj.data,C.sel_registerName(sel),arguments) }
return `Wrapper { ([objc_msgSend_type](C.objc_msgSend))(obj.data,C.sel_registerName(sel),arguments) }
end)

function mangleSelector(sel,nargs)
Expand Down
2 changes: 1 addition & 1 deletion tests/luaapi.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
terralib.includepath = terralib.terrahome.."/include/terra"
terralib.includepath = terralib.includepath .. ";" .. terralib.terrahome .. "/include/terra"
C = terralib.includecstring [[
#include "lua.h"
#include "lauxlib.h"
Expand Down
25 changes: 21 additions & 4 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ if [[ $(uname) = Darwin ]]; then
hdiutil detach /Volumes/CUDAMacOSXInstaller
fi

# workaround for https://github.com/terralang/terra/issues/365
if [[ ! -e /usr/include ]]; then
export INCLUDE_PATH="$(xcrun --sdk macosx --show-sdk-path)/usr/include"
fi

export PATH=$PWD:$PATH
fi

Expand All @@ -167,16 +172,28 @@ if [[ $USE_CMAKE -eq 1 ]]; then
-DTERRA_SLIB_INCLUDE_LUAJIT=OFF
)
fi
if [[ $(uname) = Darwin ]]; then
# Hack: CMake tries to be smart and use XCode's copy of Clang by
# default. This causes LuaJIT to not build on Mojave and later
# (math.h not found) if the header package is not installed.
CMAKE_FLAGS+=(
-DCMAKE_C_COMPILER=$(which $CC)
-DCMAKE_CXX_COMPILER=$(which $CXX)
)
fi

pushd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install "${CMAKE_FLAGS[@]}"
make install -j2
ctest -j2 || (test "$(uname)" = "Darwin" && test "$LLVM_CONFIG" = "llvm-config-3.8")
ctest --output-on-failure -j2 || (test "$(uname)" = "Darwin" && test "$LLVM_CONFIG" = "llvm-config-3.8")
popd

pushd tests
../install/bin/terra ./run
popd
# Skip this on macOS because it spews too much on Mojave and newer.
if [[ $(uname) != Darwin ]]; then
pushd tests
../install/bin/terra ./run
popd
fi
else
make LLVM_CONFIG=$(which $LLVM_CONFIG) CLANG=$(which $CLANG) test

Expand Down