<div dir="ltr">I added some autoconf magic in order to detect missing inb,outb functions. It might not be the best solution<div>as I'm no autoconf expert but it solves my problems.<br><div><br></div><div><a href="https://raw.githubusercontent.com/luizluca/openwrt-packages/e11fbf71f7f437c64d18929e7895dbaafa8c3293/utils/sane-backends/patches/020-inb_outb.patch">https://raw.githubusercontent.com/luizluca/openwrt-packages/e11fbf71f7f437c64d18929e7895dbaafa8c3293/utils/sane-backends/patches/020-inb_outb.patch</a><br></div><div><br></div><div>Regards,</div></div></div><br><div class="gmail_quote"><div dir="ltr">Em qui, 10 de set de 2015 às 01:14, Luiz Angelo Daros de Luca <<a href="mailto:luizluca@gmail.com">luizluca@gmail.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I checked with other libc and got some more info about the problem.</div><div><br></div><div>Normally, sane-backends deal with ioperm/inb/outb like this:</div><div>a) sane-backends tries to use sys/io.h in order to provide inb/outb. If missing, it implements them locally but only for i386 (old glibc?)</div><div>b) if ioperm is missing for any arch but i386. <span style="font-size:13.2px;line-height:19.8px">IO_SUPPORT_MISSING is defined </span></div><div><span style="font-size:13.2px;line-height:19.8px">c) if either ioperm is missing or </span><span style="font-size:13.2px;line-height:19.8px">IO_SUPPORT_MISSING is defined, inb/outb will not be used.</span></div><div><span style="line-height:1.5;font-size:13.2px">c.1) the exception is </span><span style="line-height:19.8px;font-size:13.2px">backend/qcam.c, which tries to use inb/outb anyway but it will not be compiled if ioperm is missing.</span><br></div><div><br></div><div>Now how libc implementations deal with iopem/inb/oub:</div><div><br></div><div><span style="font-size:13.2px;line-height:19.8px">When uclibc is used:<br></span><span style="font-size:13.2px;line-height:19.8px">* it provide </span><span style="font-size:13.2px;line-height:19.8px">sys/io.h for only </span><span style="font-size:13.2px;line-height:19.8px">i386/x32/x86_64 archs and it includes</span><span style="font-size:13.2px;line-height:19.8px"> inb/outb</span><span style="font-size:13.2px;line-height:19.8px"><br></span></div><div><span style="font-size:13.2px;line-height:19.8px">* it does not provide </span><span style="font-size:13.2px;line-height:19.8px">sys/io.h for non i386 arch</span><br></div><div>When musl is used:</div><div>* it provides <span style="font-size:13.2px;line-height:19.8px">sys/io.h for any arch that has ioperm syscall (which includes mips, </span><span style="font-size:13.2px;line-height:19.8px">i386/x32/x86_64</span><span style="font-size:13.2px;line-height:19.8px">, </span>powerpc, microblaze<span style="font-size:13.2px;line-height:19.8px">)</span></div><div><span style="font-size:13.2px;line-height:19.8px">* it does not provide inb/outb for any arch expect i386/x32/x86_64 (using bits/io.h included in sys/io.h)</span></div><div><br></div><div>What happens on sane-backend:</div><div><div style="font-size:13.2px;line-height:19.8px"><span style="line-height:1.5;font-size:13.2px">1) for </span><span style="font-size:13.2px;line-height:19.8px">i386/x32/x86_64 arch, any libc provides sys/io.h with ioperm and inb/oub. </span><span style="font-size:13.2px;line-height:19.8px">Sane-backends compiles.</span></div><div style="font-size:13.2px;line-height:19.8px"></div></div><div>2) for any arch that does not implement ioperm syscall, <span style="font-size:13.2px;line-height:19.8px">ioperm is missing. Sane-backends compiles.</span></div><div><span style="font-size:13.2px;line-height:1.5">3) for other non-</span><span style="font-size:13.2px;line-height:19.8px">i386/x32/x86_64-arch</span><span style="font-size:13.2px;line-height:1.5"> that provides ioperm syscall:</span><br></div><div style="font-size:13.2px;line-height:19.8px"><span style="font-size:13.2px;line-height:1.5">3.1) uclibc does not provide sys.io.h. </span><span style="font-size:13.2px;line-height:19.8px">Sane-backends compiles</span><span style="font-size:13.2px;line-height:19.8px">, except for qcam.</span></div><div style="font-size:13.2px;line-height:19.8px"><span style="font-size:13.2px;line-height:1.5">3.2) musl provide sys.io.h but inb/outb is missing. </span><span style="font-size:13.2px;line-height:19.8px">Sane-backends fails with multiple undefined symbols (inb/outb).</span></div><div><br></div><div><span style="font-size:13.2px;line-height:19.8px">Some files affected are:</span></div><div><span style="font-size:13.2px;line-height:19.8px">sanei/sanei_pio.c</span><br></div><div>sanei/sanei_ab306.c<br></div><div>sanei/sanei_pa4s2.c<br></div><div>sanei/sanei_pp.c<br></div><div>backend/umax_pp_low.c<br></div><div><span style="font-size:13.2px;line-height:19.8px">backend/qcam.c</span><br></div><div><br></div><div>What is the best solution here? Should all checks for ioperm be replaced by (or added with) checks for inb/outb (including disabling qcam in configure)?</div><div>It'll not break cases 1), 2) and it will fix 3.1 and 3.2.</div><div><br></div><div>Regards,</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">Em qua, 9 de set de 2015 às 19:04, Luiz Angelo Daros de Luca <<a href="mailto:luizluca@gmail.com" target="_blank">luizluca@gmail.com</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I'm trying to get rid of this patch:</div><div><a href="http://git.openwrt.org/?p=packages.git;a=blob_plain;f=utils/sane-backends/patches/020-non-i386-qcam.patch;hb=HEAD" target="_blank">http://git.openwrt.org/?p=packages.git;a=blob_plain;f=utils/sane-backends/patches/020-non-i386-qcam.patch;hb=HEAD</a><br></div><div><br></div><div>That helps sane-backend cross-compile for MIPS processor. But this seems to be a hacky solution.</div><div><br></div><div>The problem seems that configure check for ioperm passes for MIPS with libc-musl (I didn't test with other libc), while inb and outb are still missing for this arch. As sane-backend uses HAVE_IOPERM in order to use or not in/outb, it compiles requiring inb/outb. This results in a linker error.</div><div><br></div><div>Who is not playing nice here? musl providing ioperm where it shouldn't? configure failing to check correcly for ioperm? sane not checking for inb?</div><div><br></div><div>Regards,</div></div></blockquote></div></blockquote></div>