title: Port glibc 2.25 and test memory functions
body: <p>I was investigating whether a few memory functions(memcpy, memset, memmove) in glibc-2.25 with various versions(sse4, ssse3, avx2, avx512) could have performance gain for our server programs in Linux(glibc 2.12).<br>
  My first attempt was to download a tar ball of glibc-2.25 and build/test following the instructions here <a href="https://sourceware.org/glibc/wiki/Testing/Builds" rel="nofollow noreferrer">https://sourceware.org/glibc/wiki/Testing/Builds</a>. I manually commented out kernel version check and everything went well. Then a test program was linked with newly built glibc with the procedure listed in section "Compile against glibc build tree" of glibc wiki and 'ldd test' shows that it indeed depended on the expected libraries:  </p>
  
  <pre><code>    # $GLIBC is /data8/home/wentingli/temp/glibc/build
      libm.so.6 =&gt; /data8/home/wentingli/temp/glibc/build/math/libm.so.6 (0x00007fe42f364000)
      libc.so.6 =&gt; /data8/home/wentingli/temp/glibc/build/libc.so.6 (0x00007fe42efc4000)
      /data8/home/wentingli/temp/glibc/build/elf/ld-linux-x86-64.so.2 =&gt; /lib64/ld-linux-x86-64.so.2 (0x00007fe42f787000)
      libdl.so.2 =&gt; /data8/home/wentingli/temp/glibc/build/dlfcn/libdl.so.2 (0x00007fe42edc0000)
      libpthread.so.0 =&gt; /data8/home/wentingli/temp/glibc/build/nptl/libpthread.so.0 (0x00007fe42eba2000)
  </code></pre>
  
  <p>I use gdb to verify which memset/memcpy was actually called but it always shows that __memset_sse2_unaligned_erms is used while I was expecting that some more advanced version of the function(avx2,avx512) could be <a href="https://i.stack.imgur.com/Hosb4.png" rel="nofollow noreferrer">in use</a>.
  My questions are:</p>
  
  <ol>
  <li>Did glibc-2.25 select the most suitable version of memory functions automatically according to cpu/os/memory address? If not, am I missing any configuration during glibc build or something wrong with my setup?</li>
  <li>Is there any other alternatives for porting memory functions from newer glibc?</li>
  </ol>
  
  <p>Any help or suggestion would be appreciated.</p>