cling icon indicating copy to clipboard operation
cling copied to clipboard

Cling fails to build on Ubuntu 22.04 LTS

Open dimitry-ishenko opened this issue 3 years ago • 1 comments

  • [x] Checked for duplicates

Describe the bug

Running cpt.py --current-dev=deb results in several failures:

In file included from /root/ci/build/cling-src/utils/benchmark/src/benchmark_register.cc:15:
/root/ci/build/cling-src/utils/benchmark/src/benchmark_register.h: In function 'void AddRange(std::vector<T>*, T, T, int)':
/root/ci/build/cling-src/utils/benchmark/src/benchmark_register.h:17:30: error: 'numeric_limits' is not a member of 'std'
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                              ^~~~~~~~~~~~~~
/root/ci/build/cling-src/utils/benchmark/src/benchmark_register.h:17:46: error: expected primary-expression before '>' token
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                                              ^
/root/ci/build/cling-src/utils/benchmark/src/benchmark_register.h:17:49: error: '::max' has not been declared; did you mean 'std::max'?
   17 |   static const T kmax = std::numeric_limits<T>::max();
      |                                                 ^~~
      |                                                 std::max
In file included from /usr/include/c++/11/algorithm:62,
                 from /root/ci/build/cling-src/utils/benchmark/include/benchmark/benchmark.h:175,
                 from /root/ci/build/cling-src/utils/benchmark/src/internal_macros.h:4,
                 from /root/ci/build/cling-src/utils/benchmark/src/check.h:8,
                 from /root/ci/build/cling-src/utils/benchmark/src/benchmark_register.h:6,
                 from /root/ci/build/cling-src/utils/benchmark/src/benchmark_register.cc:15:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: 'std::max' declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
make[2]: *** [utils/benchmark/src/CMakeFiles/benchmark.dir/build.make:90: utils/benchmark/src/CMakeFiles/benchmark.dir/benchmark_register.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....

This can be fixed by adding the missing header:

--- ci/build/cling-src/utils/benchmark/src/benchmark_register.h.orig	2022-07-29 12:54:09.060470215 -0400
+++ ci/build/cling-src/utils/benchmark/src/benchmark_register.h	2022-07-29 12:21:57.744017822 -0400
@@ -1,6 +1,7 @@
 #ifndef BENCHMARK_REGISTER_H
 #define BENCHMARK_REGISTER_H
 
+#include <limits>
 #include <vector>
 
 #include "check.h"

Next failure is caused by llvm-lit trying to use python 2:

[100%] Running the Cling regression tests
llvm-lit: /root/ci/build/cling-src/utils/lit/lit/llvm/config.py:340: note: using clang: /root/ci/build/builddir/bin/clang
llvm-lit: /root/ci/build/cling-src/utils/lit/lit/llvm/subst.py:126: note: Did not find opt in /root/ci/build/builddir/bin
Traceback (most recent call last):
  File "/root/ci/build/builddir/bin/llvm-lit", line 39, in <module>
    main(builtin_parameters)
  File "/root/ci/build/cling-src/utils/lit/lit/main.py", line 194, in main
    main_with_tmp(builtinParameters)
  File "/root/ci/build/cling-src/utils/lit/lit/main.py", line 515, in main_with_tmp
    tc = lit.ProgressBar.TerminalController()
  File "/root/ci/build/cling-src/utils/lit/lit/ProgressBar.py", line 110, in __init__
    reload(sys)
NameError: name 'reload' is not defined
make[3]: *** [tools/cling/test/CMakeFiles/check-cling.dir/build.make:71: tools/cling/test/CMakeFiles/check-cling] Error 1
make[2]: *** [CMakeFiles/Makefile2:52195: tools/cling/test/CMakeFiles/check-cling.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:52202: tools/cling/test/CMakeFiles/check-cling.dir/rule] Error 2
make: *** [Makefile:12500: check-cling] Error 2
subprocess.CalledProcessError: Command 'make -j8 check-cling' returned non-zero exit status 2

This can be fixed as follows:

+++ ci/build/cling-src/utils/lit/lit/ProgressBar.py	2022-07-29 12:28:27.221805312 -0400
@@ -3,6 +3,7 @@
 # Source: http://code.activestate.com/recipes/475116/, with
 # modifications by Daniel Dunbar.
 
+from importlib import reload
 import sys, re, time
 
 def to_bytes(str):
@@ -108,7 +109,7 @@
 
         # We want unicode output and have unicode input.
         reload(sys)
-        sys.setdefaultencoding('utf8')
+        #sys.setdefaultencoding('utf8')
 
         # Look up numeric capabilities.
         self.COLS = curses.tigetnum('cols')

Then there are multiple failing tests:

********************
Testing Time: 20.04s
********************
Failing Tests (24):
    Cling :: CodeUnloading/RunAgainstClangTestSuite/RunAgainstClangTestSuite.C
    Cling :: DynamicLibraryManager/cached_realpath.C
    Cling :: Extensions/Lookup/Arrays.C
    Cling :: Extensions/Lookup/ControlFlow.C
    Cling :: Extensions/Lookup/LifetimeHandler.C
    Cling :: Extensions/Lookup/Simple.C
    Cling :: Extensions/Lookup/SimpleDynamicExprs.C
    Cling :: Extensions/Lookup/StillError.C
    Cling :: Interfaces/evaluate.C
    Cling :: Interfaces/transactionReuse.C
    Cling :: Lookup/args.C
    Cling :: Lookup/data.C
    Cling :: Lookup/func.C
    Cling :: Lookup/named.C
    Cling :: Lookup/scope.C
    Cling :: Lookup/template.C
    Cling :: Lookup/type.C
    Cling :: NullDeref/ExecutionTermination.C
    Cling :: NullDeref/InvalidMemoryAddress.C
    Cling :: Pragmas/opt.C
    Cling :: Prompt/MetaProcessor/DotO.C
    Cling :: Prompt/ValuePrinter/Regression.C
    Cling :: Prompt/ValuePrinter/Strings.C
    Cling :: Utils/Transform.C

  Expected Passes    : 134
  Expected Failures  : 13
  Unsupported Tests  : 14
  Unexpected Failures: 24

Full build.log of failing tests.

Not sure what to do here, other than skipping the tests with --no-tests.

Next we get these two errors:

┌──────────────────────────────────────────────────────────────────────────────┐
│ Compress compiled binaries into a bzip2 tarball                              │
└──────────────────────────────────────────────────────────────────────────────┘
subprocess.CalledProcessError: Command 'gpg --fingerprint | grep uid | sed s/uid *//g' returned non-zero exit status 2
...
...
┌──────────────────────────────────────────────────────────────────────────────┐
│ Set up the debian directory                                                  │
└──────────────────────────────────────────────────────────────────────────────┘
Create directory: debian
Create directory: /root/ci/build/cling-1.0~dev-0b684e3/debian/source
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/format
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/lintian-overrides
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/cling.install
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compact
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compat
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/control
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/copyright
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/rules
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/changelog
subprocess.CalledProcessError: Command 'git log v0.9...HEAD --format=  * %s | fmt -s' returned non-zero exit status 128

Did someone seriously think they could just use pipes in subprocess.check_output???

--- cpt.py.orig	2022-07-29 14:27:34.390555872 -0400
+++ cpt.py	2022-07-29 14:28:53.331770266 -0400
@@ -908,7 +908,7 @@
 
 
 def debianize():
-    SIGNING_USER = exec_subprocess_check_output('gpg --fingerprint | grep uid | sed s/"uid *"//g',
+    SIGNING_USER = exec_subprocess_check_output('sh -c "gpg --fingerprint | grep uid | sed \'s/uid *//g\'"',
                                                 CLING_SRC_DIR).strip()
 
     box_draw("Set up the debian directory")
@@ -1081,7 +1081,7 @@
 
     if '~dev' in VERSION:
         TAG = str(float(VERSION[:VERSION.find('~')]) - 0.1)
-        template = exec_subprocess_check_output('git log v' + TAG + '...HEAD --format="  * %s" | fmt -s', CLING_SRC_DIR)
+        template = exec_subprocess_check_output('sh -c "git log v' + TAG + '...HEAD --format=\'  * %s\' | fmt -s"', CLING_SRC_DIR)
 
         f = open(os.path.join(prefix, 'debian', 'changelog'), 'a+')
         f.write(template)

Not done yet:

┌──────────────────────────────────────────────────────────────────────────────┐
│ Set up the debian directory                                                  │
└──────────────────────────────────────────────────────────────────────────────┘
Create directory: debian
Create directory: /root/ci/build/cling-1.0~dev-0b684e3/debian/source
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/format
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/lintian-overrides
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/cling.install
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compact
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compat
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/control
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/copyright
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/rules
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/changelog
Traceback (most recent call last):
  File "/root/./cpt.py", line 2196, in <module>
    debianize()
  File "/root/./cpt.py", line 1104, in debianize
    if STABLE_FLAG != '1':
UnboundLocalError: local variable 'STABLE_FLAG' referenced before assignment

And then some more (subprocess shenanigans):

┌──────────────────────────────────────────────────────────────────────────────┐
│ Set up the debian directory                                                  │
└──────────────────────────────────────────────────────────────────────────────┘
Create directory: debian
Create directory: /root/ci/build/cling-1.0~dev-0b684e3/debian/source
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/format
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/lintian-overrides
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/cling.install
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compact
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compat
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/control
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/copyright
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/rules
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/changelog
subprocess.CalledProcessError: Command 'git log v0.9...v0.8--format=  * %s | fmt -s' returned non-zero exit status 128

Fixed by:

--- cpt.py.orig	2022-07-29 14:27:34.390555872 -0400
+++ cpt.py	2022-07-29 14:52:12.818092050 -0400
@@ -1079,9 +1079,10 @@
     f.write(template.lstrip())
     f.close()
 
+    STABLE_FLAG = ''
     if '~dev' in VERSION:
         TAG = str(float(VERSION[:VERSION.find('~')]) - 0.1)
-        template = exec_subprocess_check_output('git log v' + TAG + '...HEAD --format="  * %s" | fmt -s', CLING_SRC_DIR)
+        template = exec_subprocess_check_output('sh -c "git log v' + TAG + '...HEAD --format=\'  * %s\' | fmt -s"', CLING_SRC_DIR)
 
         f = open(os.path.join(prefix, 'debian', 'changelog'), 'a+')
         f.write(template)
@@ -1106,7 +1107,7 @@
             f.write('cling (' + TAG + '-1) unstable; urgency=low\n')
             f.close()
             STABLE_FLAG = '1'
-            template = exec_subprocess_check_output('git log v' + CMP + '...v' + TAG + '--format="  * %s" | fmt -s',
+            template = exec_subprocess_check_output('sh -c "git log v' + CMP + '...v' + TAG + ' --format=\'  * %s\' | fmt -s"',
                                                     CLING_SRC_DIR)
 
             f = open(os.path.join(prefix, 'debian', 'changelog'), 'a+')

And this is just icing on the cake:

https://github.com/root-project/cling/blob/0b684e39da807b2c7988535255d15ad55f6e35df/tools/packaging/cpt.py#L1134-L1136

Pardon my French, but are you effing kidding me? How could someone write such a thing? The resulting TAG values are:

TAG = 0.9
TAG = 0.8
TAG = 0.7000000000000001
TAG = 0.6000000000000001
TAG = 0.5000000000000001
TAG = 0.40000000000000013
TAG = 0.30000000000000016
TAG = 0.20000000000000015
TAG = 0.10000000000000014
TAG = 1.3877787807814457e-16
TAG = -0.09999999999999987
TAG = -0.19999999999999987
TAG = -0.2999999999999999
TAG = -0.3999999999999999
TAG = -0.4999999999999999
TAG = -0.5999999999999999
TAG = -0.6999999999999998
TAG = -0.7999999999999998
TAG = -0.8999999999999998
TAG = -0.9999999999999998
TAG = -1.0999999999999999
TAG = -1.2
TAG = -1.3

Which leads to an endless loop. Didn't we all learn in school that doing this kind of stuff with floats is extremely dangerous?

And just because we are having so much "fun":

┌──────────────────────────────────────────────────────────────────────────────┐
│ Set up the debian directory                                                  │
└──────────────────────────────────────────────────────────────────────────────┘
Create directory: debian
Create directory: /root/ci/build/cling-1.0~dev-0b684e3/debian/source
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/format
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/source/lintian-overrides
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/cling.install
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compact
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/compat
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/control
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/copyright
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/rules
Create file: /root/ci/build/cling-1.0~dev-0b684e3/debian/changelog
Traceback (most recent call last):
  File "/root/./cpt.py", line 2197, in <module>
    debianize()
  File "/root/./cpt.py", line 1129, in debianize
    f.write(template.encode('utf-8'))
TypeError: write() argument must be str, not bytes

Up until this line:

https://github.com/root-project/cling/blob/0b684e39da807b2c7988535255d15ad55f6e35df/tools/packaging/cpt.py#L1161

everything was written without utf-8 and then suddenly someone had this urge to covert to utf-8 here...

--- cpt.py.orig	2022-07-29 14:27:34.390555872 -0400
+++ cpt.py	2022-07-29 15:07:31.847832112 -0400
@@ -1125,7 +1126,7 @@
     template = exec_subprocess_check_output('git log v0.1 --format="  * %s%n -- %an <%ae>  %cD%n"', CLING_SRC_DIR)
 
     f = open(os.path.join(prefix, 'debian', 'changelog'), 'a+')
-    f.write(template.encode('utf-8'))
+    f.write(template)
     f.close()
 
     box_draw("Run debuild to create Debian package")

And in the end it still failed:

┌──────────────────────────────────────────────────────────────────────────────┐
│ Run debuild to create Debian package                                         │
└──────────────────────────────────────────────────────────────────────────────┘
 dpkg-buildpackage -us -uc -ui
dpkg-buildpackage: info: source package cling
dpkg-buildpackage: info: source version 1.0~dev-0b684e3-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by [ultimate] admin <admin@laptop>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
 debian/rules clean
dh clean
dh: warning: Compatibility levels before 10 are deprecated (level 9 in use)
   dh_clean
dh_clean: warning: Compatibility levels before 10 are deprecated (level 9 in use)
 dpkg-source -b .
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building cling using existing ./cling_1.0~dev-0b684e3.orig.tar.bz2
dpkg-source: info: building cling in cling_1.0~dev-0b684e3-1.debian.tar.xz
dpkg-source: info: building cling in cling_1.0~dev-0b684e3-1.dsc
 debian/rules build
dh build
dh: warning: Compatibility levels before 10 are deprecated (level 9 in use)
   dh_update_autotools_config
 debian/rules binary
dh binary
dh: warning: Compatibility levels before 10 are deprecated (level 9 in use)
   dh_testroot
   dh_prep
   dh_install
dh_install: warning: Compatibility levels before 10 are deprecated (level 9 in use)
dh_install: warning: Cannot find (any matches for) "docs/*" (tried in ., debian/tmp)

dh_install: warning: cling missing files: docs/*
dh_install: warning: Cannot find (any matches for) "share/*" (tried in ., debian/tmp)

dh_install: warning: cling missing files: share/*
dh_install: error: missing files, aborting
make: *** [debian/rules:5: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed
subprocess.CalledProcessError: Command 'debuild' returned non-zero exit status 29

At this point I gave up. It's been a while since I've seen such a low quality of code.

Expected behavior

I expect .deb package to be produced.

To Reproduce

Execute cpt.py --current-dev=deb.

Setup

  1. Cling version: 1.0~dev
  2. Operating system: Ubuntu 22.04
  3. How you obtained Cling: I haven't yet...

Additional context

dimitry-ishenko avatar Jul 29 '22 17:07 dimitry-ishenko

FWIW I've created proper Debian packaging for Cling here:

https://github.com/dimitry-ishenko-cpp/cling-packaging

You can also install Cling on Ubuntu 22.04 from my PPA here:

https://launchpad.net/~ppa-verse/+archive/ubuntu/xeus-cling

dimitry-ishenko avatar Aug 17 '22 15:08 dimitry-ishenko