tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Fixing llvm in rust?



Hi,

some of you may have already seen that I've committed a "not
completely finished" version update of rust to 1.71.0 to
pkgsrc-wip/rust.  The major remaining problem is that the LLVM
which is embedded in the source tar-ball does not want to build,
or, rather, "install".  When building and using the internal LLVM
it is actually built twice, and the first one is installed into a
staging area, and I think this is where things fail.

The error message spewed is:

-- Installing: /usr/pkgsrc/wip/rust/work/rustc-1.71.0-src/build/x86_64-unknown-netbsd/llvm/bin/llvm-tblgen
CMake Error at utils/TableGen/cmake_install.cmake:50 (file):
  file RPATH_CHANGE could not write new RPATH:

    $ORIGIN/../lib

  to the file:

    /usr/pkgsrc/wip/rust/work/rustc-1.71.0-src/build/x86_64-unknown-netbsd/llvm/bin/llvm-tblgen

  The current RPATH is:

    /usr/pkg/lib

  which does not contain:

    $ORIGIN/../lib:

  as was expected.
Call Stack (most recent call first):
  cmake_install.cmake:63 (include)

That cmake_install.cmake file is only in the build tree as:

work/rustc-1.71.0-src/build/x86_64-unknown-netbsd/llvm/build/utils/TableGen/cmake_install.cmake

and is therefore most probably built from "somewhere" that I've
not been able to figure out.  I further suspect what's failing is

  if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/llvm-tblgen" AND
     NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/llvm-tblgen")
    file(RPATH_CHANGE
         FILE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/llvm-tblgen"
         OLD_RPATH "\$ORIGIN/../lib:"
         NEW_RPATH "$ORIGIN/../lib")
    if(CMAKE_INSTALL_DO_STRIP)
      execute_process(COMMAND "/usr/pkgsrc/wip/rust/work/.tools/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/llvm-tblgen")
    endif()
  endif()

Now, the pattern for one of the last c++ invocation I find in
work/.work.log looks like this:

[*] c++ -O2 -ffunction-sections -fdata-sections -fPIC -m64 ...
	-o ../../bin/llvm-reduce '-Wl,-rpath,$ORIGIN/../lib:'

followed by

<.> /usr/pkgsrc/wip/rust/work/.gcc/bin/g++ -Wl,-zrelro -std=c++17 -O2 ...
	-o ../../bin/llvm-reduce ../../lib/libLLVMAArch64AsmParser.a

and I suspect this is cwrapper which strips away the $ORIGIN
construct, thus, the rpath does not get inserted in the
executable, and therefore the above cmake construct will
inevitably fail.


At this point I'm about at my wits end with how to go about fixing
this.

One theoretical possibility is to fix cwrappers not to discard
arguments with relative paths, but I'm guessing this is going to be
met with serious opposition.

Another could be to find a way to just rip out the "file(RPATH_CHANGE
..." construct, but since this appears to only exist in generated
cmake-files, I need help to figure out where this actually comes from
(and it's not a given that ripping it out is actually going to make
the build work).

I've also tried to do

# Try to see if this works with internal LLVM:
CONFIGURE_ARGS+=        --set rust.rpath=false

but the same problem as shown above still happens.

Does anyone have any suggestions?

Regards,

- Håvard


Home | Main Index | Thread Index | Old Index