I assume you are on an architecture where the linker is LLVM ld,
otherwise known as ld-lld in OpenBSD (some older architectures
still use ld-bfd).

In llvm/lib/Support/Path.cpp, there is code that acts just like you describe:

void createUniquePath(const Twine &Model, SmallVectorImpl<char> &ResultPath,
                      bool MakeAbsolute) {
...
  // Replace '%' with random chars.
  for (unsigned i = 0, e = ModelStorage.size(); i != e; ++i) {
    if (ModelStorage[i] == '%')
      ResultPath[i] = "0123456789abcdef"[sys::Process::GetRandomNumber() & 15];
  }


It apppears in the LLVM universe if you try to create a file with % in the
name, it has a different interpretation of what that % means, different than
what you want it to mean.

https://docs.hdoc.io/hdoc/llvm-project/f1FB0DB2307A8013C.html

Other than that, I can find no documentation.


Andinus <andi...@nand.sh> wrote:

> Hello,
> 
> Context: https://github.com/ugexe/zef/issues/457#issuecomment-1586021352
> 
> I'm not familiar with how `ld` works so I'm not sure how to create a
> minimal reproducible example.
> 
> - zef is Raku's module manager
> - Raku: formerly Perl 6
> 
> When I try to run `zef install --debug Crypt::Bcrypt` it always fails in
> build step with this error:
> 
> ```
> ...
> Jun 01 19:01:41 [Digest::SHA1::Native] clang -shared -fPIC  -O3 -DNDEBUG 
> -Wl,-rpath,"//usr/local/rakudo/lib" -o 
> /tmp/.zef/1685626244.6528/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsha1.so
>  sha1.o
> Jun 01 19:01:41 [Digest::SHA1::Native] ld: error: cannot open output file 
> /tmp/.zef/1685626244.6528/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsha1.so:
>  No such file or directory
> Jun 01 19:01:41 [Digest::SHA1::Native] clang: error: linker command failed 
> with exit code 1 (use -v to see invocation)
> ...
> ```
> 
> This is how `ld` is invoked, the issue seems to be with '%' in directory
> name:
> ```
> andinus@cadmium /t/.z/1/D/raku-digest-sha1-native-master> "/usr/bin/ld" 
> --eh-frame-hdr -Bdynamic -shared -o 
> /tmp/.zef/1686382217.68953/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsha1.so
>  /usr/lib/crtbeginS.o -L/usr/lib -rpath //usr/local/rakudo/lib sha1.o 
> -lcompiler_rt -lcompiler_rt /usr/lib/crtendS.o
> ld: error: cannot open output file 
> /tmp/.zef/1686382217.68953/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsha1.so:
> No such file or directory
> ```
> 
> Quoting the path doesn't work, even escaping '%' with \ doesn't seem to
> work. What works is removing % from path altogether.
> 
> Here is ktrace output:
> ```
>  23633 ld       NAMI  
> "/tmp/.zef/1686382217.68953/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsh\
>         a1.so"
>  23633 ld       RET   stat -1 errno 2 No such file or directory
>  23633 ld       CALL  kbind(0x7f0992e23f18,24,0xf17447ef4e72dc56)
>  23633 ld       RET   kbind 0
>  23633 ld       CALL  
> open(0x29843bc00,0x10a02<O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC>,0666<S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH>)
>  23633 ld       NAMI  
> "/tmp/.zef/1686382217.68953/Digest73A43ASHA143A73ANativef3Aver73C0.0613E23Aauth73Cgithuba3Abduggan13E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsh\
>         a1.so.tmpc5eb445"
>  23633 ld       RET   open -1 errno 2 No such file or directory
>  23633 ld       CALL  kbind(0x7f0992e244e8,24,0xf17447ef4e72dc56)
>  23633 ld       RET   kbind 0
> .
> .
> .
>  23633 ld       RET   kbind 0
>  23633 ld       CALL  write(2,0x7f0992e24501,0x2)
>  23633 ld       GIO   fd 2 wrote 2 bytes
>        "ld"
>  23633 ld       RET   write 2
>  23633 ld       CALL  write(2,0x3a9837,0x2)
>  23633 ld       GIO   fd 2 wrote 2 bytes
>        ": "
>  23633 ld       RET   write 2
>  23633 ld       CALL  write(2,0x336c72,0x7)
>  23633 ld       GIO   fd 2 wrote 7 bytes
>        "error: "
>  23633 ld       RET   write 7
>  23633 ld       CALL  write(2,0x4a96e1,0x18)
>  23633 ld       GIO   fd 2 wrote 24 bytes
>        "cannot open output file "
>  23633 ld       RET   write 24/0x18
>  23633 ld       CALL  write(2,0x7f0992e25008,0xa9)
>  23633 ld       GIO   fd 2 wrote 169 bytes
>        
> "/tmp/.zef/1686382217.68953/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsha1.so"
>  23633 ld       RET   write 169/0xa9
>  23633 ld       CALL  write(2,0x3a9837,0x2)
>  23633 ld       GIO   fd 2 wrote 2 bytes
>        ": "
>  23633 ld       RET   write 2
>  23633 ld       CALL  write(2,0x298433740,0x19)
>  23633 ld       GIO   fd 2 wrote 25 bytes
>        "No such file or directory"
>  23633 ld       RET   write 25/0x19
>  23633 ld       CALL  write(2,0x40431f,0x1)
>  23633 ld       GIO   fd 2 wrote 1 bytes
>        "
>        "
> .
> .
> .
> ```
> 
> If you notice the 2nd `NAMI`:
> ```
>  23633 ld       NAMI  
> "/tmp/.zef/1686382217.68953/Digest%3A%3ASHA1%3A%3ANative%3Aver%3C0.06%3E%3Aauth%3Cgithub%3Abduggan%3E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsh\
>         a1.so"
> ...
>  23633 ld       NAMI  
> "/tmp/.zef/1686382217.68953/Digest73A43ASHA143A73ANativef3Aver73C0.0613E23Aauth73Cgithuba3Abduggan13E.tar.gz/raku-digest-sha1-native-master/resources/libraries/libsh\
>         a1.so.tmpc5eb445"
> ```
> 
> ld seems to interpret those '%' weirdly, it turns them into some
> alphanumeric character.
> 
> I suspect this might be what is causing this issue.

Reply via email to