<div dir="ltr">Hey all,<div><br></div><div>I think I may have figured out a new way to build manylinux1 on non-CentOS 5 machines with newer toolchains, at least in relatively simple cases. The thing that prevents most libraries from being manylinux1-compatible is that they link against too-recent versioned symbols in glibc. This suggests, then, that we might be able to fix the problem during compilation by forcing the linker to link the libraries against older (manylinux1 compatible) symbols. It seems like there are some <a href="https://stackoverflow.com/a/8862631">assembly + linker tricks</a> (also <a href="http://web.archive.org/web/20160107032111/http://www.trevorpounds.com/blog/?p=103">this</a>) that work to force just that.</div><div><br></div><div>In order to test this out, I took a look at the symbols that were causing manylinux1 incompatibility in a project of mine when compiled on CentOS 7. In this case, it was just memcpy@@GLIBC_2.14.</div><div><br></div><div>So, I dropped this file into my project:</div><div>```<br></div><div><div>$ cat memcpy.c</div><div>#include <string.h></div><div><br></div><div>asm (".symver memcpy, memcpy@GLIBC_2.2.5");</div><div>void *__wrap_memcpy(void *dest, const void *src, size_t n) {</div><div>  return memcpy(dest, src, n);</div><div>}</div></div><div>```</div><div><br></div><div>And then modified my setup.py to</div><div><br></div><div>````</div><div><div>+def manylinux1(extensions):</div><div>+    for ext in extensions:</div><div>+        ext.sources.append('memcpy.c')</div><div>+        ext.extra_link_args.append('-Wl,--wrap=memcpy')</div><div>+    return extensions</div><div>+</div></div><div><br></div><div> setup(name='project_name</div><div>       author='Robert McGibbon',</div><div>       author_email='<a href="mailto:rmcgibbo@gmail.com">rmcgibbo@gmail.com</a>',',<br></div><div><div>-      ext_modules=extensions,</div><div>+      ext_modules=manylinux1(extensions),</div></div><div>```</div><div><br></div><div><br></div><div>Lo and behold, it actually works! Obviously one would have to wrap more symbols for other projects that make heavier use of glibc and there's nothing that this can do about the fact for wheels that link against external, precompiled libraries that auditwheel grafts into the manylinux wheel, since it requires changes to the compile, but it's still cool.</div><div><br></div><div>Has anyone tried this kind of thing before?</div><div><br></div><div>-- <br><div class="gmail_signature"><div dir="ltr"><div>-Robert</div></div></div>
</div></div>