SoftCreatR / imei

IMEI - ImageMagick Easy Install
ISC License
309 stars 36 forks source link

Illegal instruction in Docker #96

Closed SoftCreatR closed 1 year ago

SoftCreatR commented 1 year ago
          Is the imei6.10 working for you?
$ identify --version
Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 98eceff6a:20230729 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib
Compiler: gcc (11.4)

$ identify /usr/share/yelp/icons/hicolor/16x16/status/yelp-page-ui.png
Illegal instruction (core dumped)

Tested under Ubuntu 22.04.2 LTS.

If you want, I can post the links to my built packages so that you can take a look / try at your side as well.

Originally posted by @suntong in https://github.com/SoftCreatR/imei/issues/92#issuecomment-1703997596

SoftCreatR commented 1 year ago

Using checkinstall, I guess? Their contents didn't change, so I have no explanation for this behavior. Maybe I can try reproducing this, later this day.

suntong commented 1 year ago

thanks for looking into it. the Dockerfile is here. The basic logic is:

ARG BASE_IMAGE=ubuntu:20.04
FROM ${BASE_IMAGE}

ARG t=/tmp/imei.sh # $(mktemp)
ARG p="--use-checkinstall --build-only --skip-aom --skip-jpeg-xl"

RUN wget 'https://dist.1-2.dev/imei.sh' -qO "$t"
RUN --mount=type=cache,target=/var/cache/apt bash "$t" $p || true && ls -l /usr/local/src/ || true

I wasn't expecting such weird error either, maybe I'll make it multi-stage build

The built .deb files are:

suntong commented 1 year ago

maybe I'll make it multi-stage build

Done, but haven't get a chance to test it yet...

suntong commented 1 year ago

The Dockerfile tested fine by itself 🤦🏻‍♂️🤦🏻‍♂️🤦🏻‍♂️ Yet I installed the built packages to my VPS and it is error with Illegal instruction (core dumped) again

The newly built package (tested fine within docker) is at https://dl.cloudsmith.io/public/suntong/repo/deb/any-distro/pool/any-version/main/i/im/imei-imagemagick_7.1.1-15-imei6.10.1/imei-imagemagick_7.1.1-15-imei6.10.1_amd64.deb

$ docker run -it ubuntu:20.04
root@870aa41f0c2e:/# 
root@870aa41f0c2e:/# uname -a
Linux 870aa41f0c2e 5.15.0-1041-azure #48-Ubuntu SMP Tue Jun 20 20:34:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

my VPS: Linux 5.15.0-82-generic #91-Ubuntu SMP Mon Aug 14 14:14:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

suntong commented 1 year ago

BTW,

I'll make it multi-stage build

  • build the .deb in on layer
  • and copy the built .deb into another layer
  • and do the installation & verification there.

I found from this way that the libxml2 is missing from the imei-imagemagick dependencies.

suntong commented 1 year ago

The Dockerfile tested fine by itself 🤦🏻‍♂️🤦🏻‍♂️🤦🏻‍♂️ Yet I installed the built packages to my VPS and it is error with Illegal instruction (core dumped) again

Building using docker image ubuntu:20.04, I found that the built packages cannot be used in other machines, but only to the built machine itself --

This is so strange, and this is the first time that I ever see such behaviour. And I tried to think hard what I had done differently when building 7.1.1-15-imei6.9.0, and I really cannot recall any differences now. Yet that package works in both my VPS and my Debian.

Would you be able to identify where the Illegal instruction come please?

SoftCreatR commented 1 year ago

It's mentioned in the readme since Checkinstall support was introduced, that this can be problematic. Especially, because it's been kind of abandoned.

suntong commented 1 year ago

OK. I'm on my own. I'll see if I can get to the bottom of it. . .

suntong commented 1 year ago

I tried to ask the question in the Debian package building community, started with:

The ImageMagick has stayed in V6 for too long and I tried to compile its V7 myself to see what the problem might be, and indeed I found a big problem -- I got "Illegal instruction" when I tried to install the built package elsewhere.

and ended with a question:

With current cloud-compiling approaches, how should we make sure that the built package works for the older x86_64 CPUs possible

I think it is a legitimate question, and the Debian community would generally benefit from an alternative source for the latest ImageMagick package, but I have just forgotten how unhelpful that mlist had been, and this time it is no exception at all. The most vocal person is also the most narrow-minded person who frowns upon all non-traditional ways of package building, and checkinstall especially, so he completely shut me off, and not even allowing other people to help at all. And indeed, I waited for a week and no one helped.

I was trying to seek a way to build the latest ImageMagick package for the general public, but now I don't care anymore. As long as I can build for myself, I'm happy, who cares the other people.

This issue can be closed now.

Renkas commented 1 year ago

I'm having same issue. But I'm not using checkinstall. Issue happens only when running my container in AWS ECS ...

I have no idea how to debug this any further so I'm going back to compiling things myself

SoftCreatR commented 1 year ago

Could you please try executing imei.sh with

--build-cflags="-O0" --build-cxxflags="-O0"
suntong commented 1 year ago

Could you please try executing imei.sh with . . .

BRAVO!!!

It works!!!

Building using docker image ubuntu:20.04, I found that the built packages cannot be used in other machines, but only to the built machine itself --

  • I tried to build with two cloud providers, and none of the the built packages can be used in my VPS.
  • I then build in my VPS and the the built packages can be used in my VPS (ubuntu:22.04).
  • however, it cannot be used in my Debian.

So I repeated above with the new flags, I.e.,

Building using docker image ubuntu:20.04 in cloud provider, and tried to run the built binary in my VPS, then tried them in my Debian, BOTH case OK!!

$ identify --version && convert -version && magick -version
Version: ImageMagick 7.1.1-20 Q16-HDRI x86_64 2cfa8d113:20231008 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib
Compiler: gcc (9.4)
Version: ImageMagick 7.1.1-20 Q16-HDRI x86_64 2cfa8d113:20231008 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib
Compiler: gcc (9.4)
Version: ImageMagick 7.1.1-20 Q16-HDRI x86_64 2cfa8d113:20231008 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib
Compiler: gcc (9.4)

This issue can be closed. Finally!

Thanks for getting to the bottom of it eventually! Cheers!

suntong commented 1 year ago

My (heavily stripped) pre-built binary that have proven to be working under both ubuntu:22.04 and Debian GNU/Linux 12 (bookworm) is available at imei-imagemagick_7.1.1-20-imei6.10.3_amd64.deb BTW, FTA.

To use it directly from repo, check out here.

SoftCreatR commented 1 year ago

Could you eventually test this as well?

--build-cflags="-O3 -mtune=generic" --build-cxxflags="-O3 -mtune=generic"
SoftCreatR commented 1 year ago

Fixed via 73b4e3738ab11f4f5623e34e365bb7a8859afd96

suntong commented 1 year ago

OK, so I gave it a try, but there something wrong with the https://dist.1-2.dev/imei.sh script. I've tried several times, and every time I'm getting Signature verification failed!

t=/tmp/imei.sh

wget 'https://dist.1-2.dev/imei.sh' -qO "$t"

$ grep '^# Version *: ' "$t"
# Version        : 6.10.4

$ sudo bash "$t"
 Signature verification failed! (2)

 Please check /var/log/imei-1697582110.log for details.

$ cat /var/log/imei-1697582110.log
Verification Failure

Please double check.

SoftCreatR commented 1 year ago

That's strange. I'll check that later. Until then, use --dev

suntong commented 1 year ago

Yeah, downloading directly from https://raw.githubusercontent.com/SoftCreatR/imei/main/imei.sh gives the same error as well.

And yes, --dev was able to make me going.

Could you eventually test this as well?

--build-cflags="-O3 -mtune=generic" --build-cxxflags="-O3 -mtune=generic"

Since the fix 73b4e37 set them as default, so I directly test calling imei.sh without any the above build cflags, and my 7.1.1-20-imei6.10.4 tested fine, FYI.

So all good.

SoftCreatR commented 1 year ago

Yeah, downloading directly from https://raw.githubusercontent.com/SoftCreatR/imei/main/imei.sh gives the same error as well.

And yes, --dev was able to make me going.

There was a bug in the workflow, that is supposed to automatically create a new release. It used an old signature file, when creating the release. I've (hopefully) fixed that, and rebased everything to 12a1d85d085a5895befa580aed46b797cff20796, so that the new 6.10.4 should be correct.

suntong commented 1 year ago

so that the new 6.10.4 should be correct.

Yes! verified just now.