On Thu, Sep 19, 2024 at 01:48:45PM +0200, Paul Gevers wrote:
> Hi,
> 
> On Mon, 16 Sep 2024 21:44:50 +0100 Julian Gilbey <j...@debian.org> wrote:
> > Possible solutions:
> > 
> > (1) Rename this (and presumably the other Python scripts in the same
> > directory) without the '.py' suffix.
> > 
> > (2) If the '.py' suffix is needed for other contexts, have a symlink
> > to them without the '.py' suffix.
> 
> (3) patch the code to find emcc in /usr/bin/

Ah!  That would work.  But I've now found the source of the problem,
and have a suggestion for how to fix it.  Shall I commit directly to
the emscripten salsa repo?

Brief summary:

* The problematic code is spread over various locations.  In the file
  cmake/Modules/Platform/Emscripten.cmake, lines 86 onwards, we have:

# Specify the compilers to use for C and C++
set(CMAKE_C_COMPILER "${EMSCRIPTEN_ROOT_PATH}/emcc${EMCC_SUFFIX}")
set(CMAKE_CXX_COMPILER "${EMSCRIPTEN_ROOT_PATH}/em++${EMCC_SUFFIX}")
set(CMAKE_NM "${EMSCRIPTEN_ROOT_PATH}/emnm${EMCC_SUFFIX}")
set(CMAKE_AR "${EMSCRIPTEN_ROOT_PATH}/emar${EMCC_SUFFIX}")
set(CMAKE_RANLIB "${EMSCRIPTEN_ROOT_PATH}/emranlib${EMCC_SUFFIX}")

  whereas in the previous version, the path was unspecified, so it
  just used the system PATH to find the scripts.

* debian/patches/2003_avoid_install_packaging.patch prevents the
  upstream install script from installing /usr/share/emscripten/emcc
  etc.

* debian/patches/2006_call_emscripten_in_PATH.patch makes the CMake
  file search for emranlib.py instead of emranlib in the guessed
  emscripten root.

* debian/rules makes a whole load of /usr/bin/* -> wrapper{,-tools}
  symlinks, and so does debian/emscripten.links, but the upstream emcc
  etc commands are a little more sophisticated and should probably be
  preferred.

So my suggestion for a fix is:

* Remove the lines from debian/patches/2003_avoid... that prevent
  installation of emar, embuilder, ..., emsize

* Revert lots of the changes in debian/patches/2006_call... that
  remove or mess with root paths

* Have wrapper exec the corresponding binary in /usr/share/emscripten
  rather than the .py variant.  That also allows dropping of
  wrapper-tools.

That should both simplify things a bit and allow the package to work
correctly.

> > I also noticed as I was trying to debug this that two of the scripts
> > do not have execute permission:
> > 
> > -rw-r--r-- 1 jdg jdg 62149 Sep  8 18:10 /usr/share/emscripten/emcc.py
> > -rw-r--r-- 1 jdg jdg 78775 Sep  8 18:10 /usr/share/emscripten/emrun.py
> > 
> > so this will also need fixing.
> Upstream dropped the executable flag, so maybe it's not meant to be called
> directly. /usr/bin/emcc calls it as an argument to $python.

Ah, indeed.  Now I understand.

One other patch I'd suggest: patch Makefile to call tools/install.py
with the --verbose flag.  I did that to understand what was going on.

Best wishes,

   Julian

Reply via email to