Subject: Re: bug#72925: Adding JPM package for Janet

From: Suhail Singh <[email-masked]>
Date: Sat, 12 Oct 2024 17:14:49 -0400

Ludovic Courtès <[email-masked]> writes:

>> +                         (wrap-program (string-append #$output "/bin/jpm")
>> +                           `("JANET_HEADERPATH" ":" prefix
>> +                             (,(string-append #$janet "/include/janet")))
>> +                           `("JANET_LIBPATH" ":" prefix
>> +                             (,(string-append #$janet "/lib")))
>> +                           `("C_INCLUDE_PATH" ":" prefix
>> +                             (,(string-append gcc-toolchain "/include")))
>> +                           `("CPLUS_INCLUDE_PATH" ":" prefix
>> +                             (,(string-append gcc-toolchain "/include/c++")
>> +                              ,(string-append gcc-toolchain "/include")))
>> +                           `("LIBRARY_PATH" ":" prefix
>> +                             (,(string-append gcc-toolchain "/lib")
>> +                              ,(string-append gcc-toolchain "/lib64")))
>> +                           `("PATH" ":" prefix
>> +                             (,(string-append gcc-toolchain "/bin")
>> +                              ,(string-append #$coreutils "/bin"))))))))))
>> +    (inputs (list bash-minimal
>> +                  ;; Lazily resolve the gcc-toolchain to avoid a circular
>> +                  ;; dependency.
>> +                  (module-ref (resolve-interface '(gnu packages commencement))
>> +                              'gcc-toolchain)))
>
> I suppose JPM shells out to GCC to compiler Janet (or C?) code, right?
>
> I’d recommend adding ‘gcc’, ‘glibc’, ‘binutils’, and ‘ld-wrapper’ to
> ‘inputs’; that’d less us avoid the ‘gcc-toolchain’ dance.

It seems "ld-wrapper" requires (gnu packages commencement) and this
results in doing the lazy dereference similar to gcc-toolchain above.
Am I doing something wrong?  If not, is the guidance still to add
"ld-wrapper" to inputs?

> Then in, the phase above, make sure to ‘search-input-file’ rather than
> direct references to these variables.

Hmm just to be clear, instead of:

#+begin_src scheme
  `("C_INCLUDE_PATH" ":" prefix
    (,(string-append gcc-toolchain "/include")))
#+end_src

What we want is something like:

#+begin_src scheme
  `("C_INCLUDE_PATH" ":" prefix
    (,(search-input-file inputs "/include")))
#+end_src

Is my understanding correct?

If so, adding "gcc", "glibc", "binutils", and "ld-wrapper" seems
insufficient to make that work.  The search-input-file for "/include"
results in a "&search-error" when building the package.

-- 
Suhail