Skip to content

Unable to build against libtiledb conda binary on macOS #253

@jdblischak

Description

@jdblischak

Summary: I was able to build TileDB-Go against libtiledb installed as a conda binary on Ubuntu but not macOS. Getting this to work is not currently urgent; I am documenting my experience below in case it becomes a priority in the future.

cc: @ihnorton
xref: #251


Building TileDB-Go against the libtiledb conda binary was straightforward. I installed libtiledb (conda install -c conda-forge tiledb) and then set the documented env vars:

$ export CPATH=$CONDA_PREFIX/include
$ export LIBRARY_PATH=$CONDA_PREFIX/lib
$ export LD_LIBRARY_PATH=$CONDA_PREFIX/lib

If I don't manually set those env vars, then it can't find libtiledb:

$ go build .
# github.com/TileDB-Inc/TileDB-Go
./array.go:6:10: fatal error: tiledb/tiledb.h: No such file or directory
    6 | #include <tiledb/tiledb.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.

As is expected, the above env vars are not sufficient for building on macOS. It cannot find the clang compiler installed in the conda env:

$ go test -v ./...
# runtime/cgo
cgo: C compiler "x86_64-apple-darwin13.4.0-clang" not found: exec: "x86_64-apple-darwin13.4.0-clang": executable file not found in $PATH
FAIL	github.com/TileDB-Inc/TileDB-Go [build failed]

When I replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH, then it can find the compiler, but then it unexpectedly fails the system libarchive is referenced instead of the one installed in the conda env.

$ go test -v ./...
dyld: Symbol not found: _iconv
  Referenced from: /usr/lib/libarchive.2.dylib
  Expected in: /Users/runner/micromamba-root/envs/nightly/lib/libiconv.2.dylib
 in /usr/lib/libarchive.2.dylib
/Users/runner/work/_temp/e8fbb84f-3bef-4e8d-8a75-22a209e66751.sh: line 16:  5184 Abort trap: 6           go test -v ./...

Notes on other things I tried:

  • Explicitly installing libarchive via conda had no effect
  • I tried replacing DYLD_LIBRARY_PATH wtih DYLD_FALLBACK_LIBRARY_PATH, but that had no effect (ie it was back to not being able to find the compiler)
  • I tried combining DYLD_FALLBACK_LIBRARY_PATH=$CONDA_PREFIX/lib and PATH=$CONDA_PREFIX/bin:$PATH, but it still couldn't find the compiler
  • I tested on a local osx-arm64. I couldn't even get the dyld error because DYLD_LIBRARY_PATH had no effect (presumably due to System Integrity Protection), and thus it couldn't find the compiler in the conda env

For anyone interested in troubleshooting this, here is my original GitHub Actions workflow that tested TileDB-Go against the nightly libtiledb conda binary on both Ubuntu and macOS. For PR #251, I switched to building libtiledb from source on macOS.

GitHub Actions workflow
name: TileDB-Go with nightly libtiledb

on:
  push:
    paths:
      - '.github/workflows/nightly.yml'
      - '.github/scripts/nightly/**'
  schedule:
    - cron: "0 4 * * *" # Every night at 4 AM UTC (11 PM EST; 12 AM EDT)
  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    name: nightly-${{ matrix.os }}-go-${{ matrix.go }}
    strategy:
      fail-fast: false
      matrix:
        go: ["1.18"]
        os: ["macos-11", "ubuntu-20.04"]
    defaults:
      run:
        shell: bash -l {0}
    steps:

    - uses: actions/checkout@v3

    - name: Install Conda environment with go and nightly libtiledb
      uses: mamba-org/provision-with-micromamba@main
      with:
        environment-file: false
        environment-name: nightly
        extra-specs: |
          sel(osx): clang
          sel(linux): gcc
          sel(osx): libarchive
          conda-forge::go=${{ matrix.go }}
          tiledb
        channels: tiledb/label/nightlies, conda-forge

    - name: Install dependencies
      run: go get -t .

    - name: Test TileDB-Go
      run: |
        export CPATH=$CONDA_PREFIX/include
        export LIBRARY_PATH=$CONDA_PREFIX/lib

        OS=$(uname)
        if [[ "$OS" == "Linux" ]]
        then
          export LD_LIBRARY_PATH=$CONDA_PREFIX/lib
        elif [[ "$OS" == "Darwin" ]]
        then
          export DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib
        else
          echo "Unrecognized OS: $OS"
          exit 1
        fi

        go test -v ./...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions