Skip to content

Integrate llama into meson & ninja build system #53

Description

@esneyder2

I reproduced all the steps from this blog "https://github.com/nelhage/llama" to build LLVM with cmake and ninja without any problems. Now I’ m trying to integrate llama into our meson & ninja based build system. We build embedded applications for four different architecture and rely on crossfiles to specify the compilers and other tools used per architecture. We have our own SDK for each processor architecture that contains all the tools required for building applications for that architecture. Currently I'm trying to integrate llamacc and llamac++ into the crossfile for just one architecture (PowerPC). At this stage I have managed to use llama update_function to create a debian image that contains our PowerPC sdk push it to AWS ECR and set up a corresponding Lambda container function. The sdk lives in /opt/poky/ppc in the container, which is the same path that it can it be found in on local dev machines. However, I’m struggling to edit our cross-file to use llamacc and llamac++ as the c and cpp compilers.

It is not quite clear for me, how environment variables can be used to control the behaviour of llamacc and llamac++ such that they know where to look for the c and c++ compilers inside the lambda function. Should I be using the LAMACC_LOCAL_CC/CXX environment variables to control that ? . Any recommendation?

These are the steps I've gone through:

  1. Created a dockerfile in images/ppc_gcc
FROM ghcr.io/nelhage/llama as llama
FROM debian:buster-slim
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
        xz-utils \
        python
RUN mkdir -p /opt/poky/
COPY ./poky-ppcsdk.sh /opt/poky/ // poky-ppcsdk.sh is the script to install powerpc sdk
RUN /opt/poky/poky-ppcsdk.sh -y -d /opt/poky/ppc  // install sdk to /opt/poky/ppc
ENTRYPOINT ["/llama_runtime"]
  1. Run llama update function
    llama update-function --create --build=images/ppc_gcc ppc_gcc

  2. Updated cross-file for ppc architecture in our build system (ppc.txt)

#Cross-file for building for ppc architecture 

[binaries]
c = ['llamacc', '-mtune=e300c3', '--sysroot=/opt/poky/ppc-poky-linux']
cpp = ['llamac++', '-mtune=e300c3', '--sysroot=/opt/poky-poky-linux']
ar = '/opt/poky/ppc/powerpc-poky-linux/powerpc-poky-linux-ar'
strip = '/opt/poky/ppc/powerpc-poky-linux-strip'
pkgconfig = '/opt/poky/ppc/usr/bin/pkg-config'


[built-in options]

# Properties used by the compilers
cpp_args = ['-fno-exceptions', '-ffunction-sections', '-fdata-sections', '-fno-working-directory', '-Werror=poison-system-directories', '-Wall', '-std=c++17', '-Wnon-virtual-dtor', '-fdiagnostics-color=always',$
cpp_link_args = ['-fuse-ld=bfd', '-Wl,--no-keep-memory']
c_args = ['-fno-exceptions', '-ffunction-sections', '-fdata-sections', '-fno-working-directory', '-Werror=poison-system-directories', '-Wall', '-std=c99', '-fdiagnostics-color=always', '-g', '-gsplit-dwarf', '-$
c_link_args = ['-fuse-ld=bfd', '-Wl,--no-keep-memory']

[host_machine]
system = 'linux'
cpu_family = 'ppc'
cpu = 'e300c3'
endian = 'big'

  1. Set up build directory using meson
    meson . .ppcbuild --cross-file ppc.txt

The error message that i'm getting is:
ERROR: Compiler llamacc --sysroot=/opt/poky/ppc-poky-linux can not compile programs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions