{"id":450,"date":"2023-06-08T03:06:09","date_gmt":"2023-06-08T03:06:09","guid":{"rendered":"https:\/\/blogs.gentoo.org\/gsoc\/?p=450"},"modified":"2023-06-08T03:06:09","modified_gmt":"2023-06-08T03:06:09","slug":"weekly-report-1-llvm-libc","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/gsoc\/2023\/06\/08\/weekly-report-1-llvm-libc\/","title":{"rendered":"Weekly report 1, LLVM libc"},"content":{"rendered":"<p>Hey! I had to start GSoC on sunday last week due to school, and I didn&#8217;t<br \/>\nthink that I&#8217;d write a weekly report for the first week but I decided to<br \/>\ndo it anyways.<\/p>\n<p>My plan for week 1 was:<br \/>\n&gt;This week I will set up a LLVM toolchain and sysroot for compiling<br \/>\n&gt;programs targeting LLVM libc. I will also start setting up a<br \/>\n&gt;\u201cllvm-libc\/Linux from Scratch\u201d chroot.<\/p>\n<p>Because I played with LLVM libc before last week I had already completed this<br \/>\ngoal. Going forward I will only work in the sysroot until setting up<br \/>\ncrossdev because it&#8217;s simple and gives me everything I need to fix<br \/>\ndependencies like Python.<\/p>\n<p>This far the project has been going pretty smooth, but I&#8217;ve also ran<br \/>\ninto some issues which I will comment on.<\/p>\n<p>The first issue was regarding SSP when setting up the LLVM<br \/>\ntoolchain. LLVM libc currently does not support stack smashing<br \/>\nprotection, and somehow compiled binaries automatically wants it if the<br \/>\ntoolchain was built with SSP enabled, even when compiling with<br \/>\n-fno-stack-protector. Probably this has something to do with internal<br \/>\nlibraries getting built with it. I spent quite a bit of time on this<br \/>\nbecause I forgot CXXFLAGS was a thing and only set CFLAGS, thinking that<br \/>\nsomething else was causing it :). Why this works out of the box on some<br \/>\nother distributions, hence not in setup docs, is because Gentoo enables<br \/>\nSSP in the clang config files.<\/p>\n<p>(See:<br \/>\nhttps:\/\/blogs.gentoo.org\/mgorny\/2022\/10\/07\/clang-in-gentoo-now-sets-default-runtimes-via-config-file\/)<\/p>\n<p>I then moved on to work on Python. When I talked with LLVM libc<br \/>\ndevelopers about this project they told me that the biggest obstacle for<br \/>\nPython would be the missing libm functions, so I decided to use Julia&#8217;s<br \/>\nopenlibm instead of the built in one.<\/p>\n<p>&gt; I\u2019d guess that python wouldn\u2019t quite work yet since we don\u2019t have all<br \/>\n&gt; of the double precision math functions yet, though you might be able<br \/>\n&gt; to fudge it by creating entrypoints that just call the single<br \/>\n&gt; precision versions.<\/p>\n<p>Openlibm just compiled and worked<br \/>\nout of the box with Python by configuring with<br \/>\n&#8211;with-libm=*libopenlibm.a*, and then substituting math.h for<br \/>\nopenlibm_math.h.<\/p>\n<p>Next week I will mostly work on Python, because libm isn&#8217;t the only<br \/>\nissue. Things like fileno, wide strings, pthread_cond are used in Python<br \/>\nand is not in LLVM libc yet. posixsource.c is particularly annoying.<br \/>\nYes, I have a time machine.<\/p>\n<p>&#8212;<br \/>\ncatcream<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey! I had to start GSoC on sunday last week due to school, and I didn&#8217;t think that I&#8217;d write a weekly report for the first week but I decided to do it anyways. My plan for week 1 was: &hellip; <a href=\"https:\/\/blogs.gentoo.org\/gsoc\/2023\/06\/08\/weekly-report-1-llvm-libc\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":177,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/450"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/users\/177"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/comments?post=450"}],"version-history":[{"count":2,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/450\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/450\/revisions\/452"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/media?parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/categories?post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/tags?post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}