Unverified Commit 7416ca5d authored by Thomas Gerbet's avatar Thomas Gerbet Committed by GitHub
Browse files

eztrace: 1.1-11 -> 2.1.1, fix build, adopt, otf2: fix cross (#388855)

parents 3b062881 6a640f04
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
diff --git a/cmake_modules/FindOTF2.cmake b/cmake_modules/FindOTF2.cmake
index 2853f92a..af1f3225 100644
--- a/cmake_modules/FindOTF2.cmake
+++ b/cmake_modules/FindOTF2.cmake
@@ -15,11 +15,11 @@ IF(NOT OTF2_CONFIG OR NOT EXISTS ${OTF2_CONFIG})
 ELSE()
   message(STATUS "OTF2 installation found. (using ${OTF2_CONFIG})")
 
-  execute_process(COMMAND ${OTF2_CONFIG} "--cppflags" OUTPUT_VARIABLE OTF2_INCLUDE_PATH)
+  execute_process(COMMAND ${OTF2_CONFIG} "--cppflags" "--target" "backend" OUTPUT_VARIABLE OTF2_INCLUDE_PATH)
   STRING(REPLACE "\n" "" OTF2_INCLUDE_PATH ${OTF2_INCLUDE_PATH})
   STRING(REPLACE "-I" "" OTF2_INCLUDE_PATH ${OTF2_INCLUDE_PATH})
   
-  execute_process(COMMAND ${OTF2_CONFIG} "--ldflags" OUTPUT_VARIABLE _LINK_LD_ARGS)
+  execute_process(COMMAND ${OTF2_CONFIG} "--ldflags" "--target" "backend" OUTPUT_VARIABLE _LINK_LD_ARGS)
   STRING( REPLACE " " ";" _LINK_LD_ARGS ${_LINK_LD_ARGS} )
   FOREACH( _ARG ${_LINK_LD_ARGS} )
     IF(${_ARG} MATCHES "^-L")
@@ -29,7 +29,7 @@ ELSE()
     ENDIF(${_ARG} MATCHES "^-L")
   ENDFOREACH(_ARG)
 
-  execute_process(COMMAND ${OTF2_CONFIG} "--libs" OUTPUT_VARIABLE _LINK_LD_ARGS)
+  execute_process(COMMAND ${OTF2_CONFIG} "--libs" "--target" "backend" OUTPUT_VARIABLE _LINK_LD_ARGS)
   STRING( REPLACE " " ";" _LINK_LD_ARGS ${_LINK_LD_ARGS} )
   FOREACH( _ARG ${_LINK_LD_ARGS} )
     IF(${_ARG} MATCHES "^-l")
+23 −0
Original line number Diff line number Diff line
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b36a8a94..74c6de2e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -195,8 +195,16 @@ set(EZTRACE_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
 #set(__PPTRACE_BINARY_TYPE "PPTRACE_BINARY_TYPE_BFD")
 #set(abs_top_builddir ${CMAKE_BINARY_DIR})
 
-set(INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
-set(INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
+  set(INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
+else()
+  set(INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
+endif()
+if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
+  set(INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
+else()
+  set(INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+endif()
 set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 
 # Subdirectory
+74 −19
Original line number Diff line number Diff line
@@ -2,43 +2,98 @@
  lib,
  stdenv,
  fetchFromGitLab,
  cmake,
  gfortran,
  libelf,
  libiberty,
  zlib,
  # Once https://gitlab.com/eztrace/eztrace/-/issues/41
  # is released we can switch to latest binutils.
  libbfd_2_38,
  libopcodes_2_38,
  autoreconfHook,
  libbfd,
  libopcodes,
  otf2,
  versionCheckHook,
}:

stdenv.mkDerivation rec {
  pname = "EZTrace";
  version = "1.1-11";
stdenv.mkDerivation (finalAttrs: {
  pname = "eztrace";
  version = "2.1.1";

  outputs = [
    "out"
    "dev"
    "lib"
    "man"
  ];

  src = fetchFromGitLab {
    owner = "eztrace";
    repo = "eztrace";
    rev = "eztrace-${version}";
    hash = "sha256-A6HMr4ib5Ka1lTbbTQOdq3kIdCoN/CwAKRdXdv9wpfU=";
    tag = "${finalAttrs.version}";
    hash = "sha256-ccW4YjEf++tkdIJLze2x8B/SWbBBXnYt8UV9OH8+KGU=";
  };

  # Possibly upstream these patches.
  patches = [
    ./0001-otf2-backend-cross.patch # To fix cross.
    ./0002-absolute-cmake-install-paths.patch # To fix generated .pc file
  ];

  postPatch = ''
    substituteInPlace src/eztrace-lib/eztrace_otf2.c \
      --replace-fail "/bin/rm" "rm"
    substituteInPlace cmake_modules/FindOTF2.cmake \
      --replace-fail "find_program(OTF2_CONFIG otf2-config REQUIRED)" \
                     "find_program(OTF2_CONFIG "${lib.getExe' otf2 "otf2-config"}" REQUIRED)" \
      --replace-fail "find_program(OTF2_PRINT otf2-print REQUIRED)" \
                     "find_program(OTF2_PRINT "${lib.getExe' otf2 "otf2-print"}" REQUIRED)"
    # 2.1.1 incorrectly reports 2.1.0. TODO: Remove after next release
    substituteInPlace CMakeLists.txt \
      --replace-fail "2.1.0" "${finalAttrs.version}"
    patchShebangs test
  '';

  strictDeps = true;

  cmakeFlags = [
    (lib.cmakeBool "EZTRACE_ENABLE_MEMORY" true)
    # This test is somewhat flaky and fails once per several rebuilds.
    (lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--exclude-regex;memory_tests")
  ];

  nativeBuildInputs = [
    cmake
    gfortran
    autoreconfHook
  ];

  buildInputs = [
    libelf
    libiberty
    zlib
    libbfd_2_38
    libopcodes_2_38
    libbfd
    libopcodes
    otf2
  ];

  doCheck = true;
  nativeCheckInputs = [
    otf2 # `otf2-print` needed by compiler_instrumentation_tests,pthread_tests,posixio_tests
  ];

  meta = with lib; {
  postInstall = ''
    moveToOutput bin/eztrace_create_plugin "$dev"
  '';

  doInstallCheck = true;
  nativeInstallCheckInputs = [ versionCheckHook ];

  meta = {
    description = "Tool that aims at generating automatically execution trace from HPC programs";
    license = licenses.cecill-b;
    maintainers = [ ];
    homepage = "https://eztrace.gitlab.io/eztrace/index.html";
    downloadPage = "https://gitlab.com/eztrace/eztrace/";
    license = lib.licenses.cecill-b;
    maintainers = [ lib.maintainers.xokdvium ];
    mainProgram = "eztrace";
    badPlatforms = [
      # Undefined symbols for architecture x86_64:
      #        >   "___cyg_profile_func_enter", referenced from:
      lib.systems.inspect.patterns.isDarwin
    ];
  };
}
})
+34 −2
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
  lib,
  stdenv,
  fetchurl,
  buildPackages,
  which,
  versionCheckHook,
}:

@@ -9,18 +11,48 @@ stdenv.mkDerivation (finalAttrs: {
  pname = "otf2";
  version = "3.1.1";

  outputs = [
    "out"
    "lib"
    "doc"
  ];

  src = fetchurl {
    url = "http://perftools.pages.jsc.fz-juelich.de/cicd/otf2/tags/otf2-${finalAttrs.version}/otf2-${finalAttrs.version}.tar.gz";
    hash = "sha256-Wk4BOlGsTteU/jXFW3AM1yA0b9p/M+yEx2uGpfuICm4=";
  };

  configureFlags = [
    "--enable-backend-test-runs"
  postPatch = ''
    substituteInPlace build-config/common/platforms/platform-backend-user-provided \
      --replace-fail 'CC=' 'CC=${stdenv.cc.targetPrefix}cc' \
      --replace-fail 'CXX=' 'CXX=${stdenv.cc.targetPrefix}c++'
    substituteInPlace build-config/common/platforms/platform-frontend-user-provided \
      --replace-fail 'CC_FOR_BUILD=' 'CC_FOR_BUILD=${buildPackages.stdenv.cc.targetPrefix}cc' \
      --replace-fail 'CXX_FOR_BUILD=' 'CXX_FOR_BUILD=${buildPackages.stdenv.cc.targetPrefix}c++'
  '';

  strictDeps = true;
  depsBuildBuild = [ buildPackages.stdenv.cc ];

  configureFlags =
    [
      (lib.enableFeature finalAttrs.finalPackage.doCheck "backend-test-runs")
      (lib.withFeature true "custom-compilers")
    ]
    ++ lib.optionals (!lib.systems.equals stdenv.buildPlatform stdenv.hostPlatform) [
      "ac_scorep_cross_compiling=yes"
    ];

  nativeBuildInputs = [
    which # used in configure script
  ];

  enableParallelBuilding = true;

  nativeInstallCheckInputs = [ versionCheckHook ];

  doCheck = true;
  enableParallelChecking = true;
  doInstallCheck = true;

  versionCheckProgram = [ "${placeholder "out"}/bin/otf2-config" ];