Kristina Brooks via llvm-dev
2018-Dec-23 10:59 UTC
[llvm-dev] How to compile glibc with clang/llvm?
Hi. Actually from reading the README, it seems to imply that it can be built with Clang 6.0.0 and above now, though it does incorporate a lot of patches not specific to Clang building so you will end up with them as well: ---------------------------------------------------------------------------- BUILDING GRTE WITH CLANG GRTE v5 and later can also be built with clang and (optionally) lld. LLVM support for GNU source code continues to evolve (as of June 2018), so the process is less straightforward, and likely to change from what is documented here. There are a number of glibc patches that make this work, including additional configure options mentioned below. The minimum version of clang is 6.0.0. If lld is to be used for linking, it needs to be newer than 6.0.0. Configure: CC=path-to-llvm/clang CXX=path-to-llvm/clang++ \ ../glibc/configure --disable-werror --with-clang --disable-float128 \ --with-lld --with-default-link --disable-multi-arch --prefix=/something ------------------------------------------------------------------------------ On 23/12/2018 02:51, Kristina Brooks wrote:> Hi. > > I've managed to do it before, with a lot of patches to Glibc, as well as ld.so and getting basic programs to start with > it. However, a lot of tests did not pass and in general I abandoned it due to the fact that Glibc source code is not > very easy to work with. > > I can upload it somewhere, not sure if there is any general interest in this kind of thing. I think current GRTE may > also be build-able with Clang (my fork was based on older GRTE which had unfinished patches to support Clang), though I > haven't had the time to look at that recently. > > I should add a huge disclaimer: this won't be easy and requires understanding the macro hell in glibc, GRTE relies on > some hacky uses of `_Pragma` to supplement for some macros otherwise not possible with Clang. Even if you do get it to > build I think it may be a waste of time to try and just implement the missing symbols in your case (or figure out why > they're not being exported). > > Thanks. > > On 22/12/2018 09:29, xuruobin via llvm-dev wrote: >> To whom it may concern, >> >> Is there a way to build glibc with clang/llvm? I’m working on enabling llvm-cov for my compiler which is a totally new arch with a libc.a built from newlib. I successfully built compiler-rt but when I typed the command ` clang++ --target=xxx -fprofile-instr-generate -fcoverage-mapping foo.cc -o foo`, the linker failed because of undefined reference to `mmap'/`ftruncate'/`mkdir'. I found these functions are supported by glibc but I cannot bulid glibc with clang/llvm(configure gave me an error “These critical programs are missing or too old: compiler”). So I want to know how can I compile glibc with clang/llvm or are there some WIP patches to help me with this requirement? >> >> Thanks, >> Ruobin. >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3992 bytes Desc: S/MIME Cryptographic Signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181223/2a6ba947/attachment.bin>
Alberto Barbaro via llvm-dev
2018-Dec-23 16:00 UTC
[llvm-dev] How to compile glibc with clang/llvm?
Hi, Could you keep us posted, or at least me? I'm interested to compile glibc as well and obtain the bitcode. Would you consider to use https://www.musl-libc.org in the meantime? Thanks On Sun, Dec 23, 2018, 12:00 Kristina Brooks via llvm-dev < llvm-dev at lists.llvm.org wrote:> Hi. > > Actually from reading the README, it seems to imply that it can be built > with Clang 6.0.0 and above now, though it does incorporate a lot of > patches not > specific to Clang building so you will end up with them as well: > > > ---------------------------------------------------------------------------- > BUILDING GRTE WITH CLANG > > GRTE v5 and later can also be built with clang and (optionally) lld. > LLVM support for GNU source code continues to evolve (as of June > 2018), so the process is less straightforward, and likely to change > from what is documented here. There are a number of glibc patches > that make this work, including additional configure options mentioned > below. > > The minimum version of clang is 6.0.0. If lld is to be used for linking, > it needs to be newer than 6.0.0. > > Configure: > > CC=path-to-llvm/clang CXX=path-to-llvm/clang++ \ > ../glibc/configure --disable-werror --with-clang --disable-float128 \ > --with-lld --with-default-link --disable-multi-arch > --prefix=/something > > ------------------------------------------------------------------------------ > > On 23/12/2018 02:51, Kristina Brooks wrote: > > Hi. > > > > I've managed to do it before, with a lot of patches to Glibc, as well as > ld.so and getting basic programs to start with > > it. However, a lot of tests did not pass and in general I abandoned it > due to the fact that Glibc source code is not > > very easy to work with. > > > > I can upload it somewhere, not sure if there is any general interest in > this kind of thing. I think current GRTE may > > also be build-able with Clang (my fork was based on older GRTE which had > unfinished patches to support Clang), though I > > haven't had the time to look at that recently. > > > > I should add a huge disclaimer: this won't be easy and requires > understanding the macro hell in glibc, GRTE relies on > > some hacky uses of `_Pragma` to supplement for some macros otherwise not > possible with Clang. Even if you do get it to > > build I think it may be a waste of time to try and just implement the > missing symbols in your case (or figure out why > > they're not being exported). > > > > Thanks. > > > > On 22/12/2018 09:29, xuruobin via llvm-dev wrote: > >> To whom it may concern, > >> > >> Is there a way to build glibc with clang/llvm? I’m working on > enabling llvm-cov for my compiler which is a totally new arch with a libc.a > built from newlib. I successfully built compiler-rt but when I typed the > command ` clang++ --target=xxx -fprofile-instr-generate -fcoverage-mapping > foo.cc -o foo`, the linker failed because of undefined reference to > `mmap'/`ftruncate'/`mkdir'. I found these functions are supported by glibc > but I cannot bulid glibc with clang/llvm(configure gave me an error “These > critical programs are missing or too old: compiler”). So I want to know how > can I compile glibc with clang/llvm or are there some WIP patches to help > me with this requirement? > >> > >> Thanks, > >> Ruobin. > >> _______________________________________________ > >> LLVM Developers mailing list > >> llvm-dev at lists.llvm.org > >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >> > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181223/02e649c5/attachment.html>
blubee blubeeme via llvm-dev
2018-Dec-23 18:53 UTC
[llvm-dev] How to compile glibc with clang/llvm?
GNU likes to use non standard extensions for convenience while LLVM/Clang would like stick to the standards. Unless GNU adopts a more standards compliant behavior OR LLVM decides to relax their adherence to the standards the tools will always be somewhat incompatible w/o major work. For example recent changes to the Linux Kernel adopted GNU goto asm; which means that Clang will not compile the kernel; I am not sure how far LLVM is willing to bend over to please the GNU nor am I certain GNU will become more standards complaint anytime soon. You might try the route of patching glibc but that might not be the best use of your time. There are other c implementations out there. Best On Mon, Dec 24, 2018 at 12:01 AM Alberto Barbaro via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > Could you keep us posted, or at least me? I'm interested to compile glibc > as well and obtain the bitcode. > > Would you consider to use https://www.musl-libc.org in the meantime? > > Thanks > > On Sun, Dec 23, 2018, 12:00 Kristina Brooks via llvm-dev < > llvm-dev at lists.llvm.org wrote: > >> Hi. >> >> Actually from reading the README, it seems to imply that it can be built >> with Clang 6.0.0 and above now, though it does incorporate a lot of >> patches not >> specific to Clang building so you will end up with them as well: >> >> >> ---------------------------------------------------------------------------- >> BUILDING GRTE WITH CLANG >> >> GRTE v5 and later can also be built with clang and (optionally) lld. >> LLVM support for GNU source code continues to evolve (as of June >> 2018), so the process is less straightforward, and likely to change >> from what is documented here. There are a number of glibc patches >> that make this work, including additional configure options mentioned >> below. >> >> The minimum version of clang is 6.0.0. If lld is to be used for linking, >> it needs to be newer than 6.0.0. >> >> Configure: >> >> CC=path-to-llvm/clang CXX=path-to-llvm/clang++ \ >> ../glibc/configure --disable-werror --with-clang --disable-float128 \ >> --with-lld --with-default-link --disable-multi-arch >> --prefix=/something >> >> ------------------------------------------------------------------------------ >> >> On 23/12/2018 02:51, Kristina Brooks wrote: >> > Hi. >> > >> > I've managed to do it before, with a lot of patches to Glibc, as well >> as ld.so and getting basic programs to start with >> > it. However, a lot of tests did not pass and in general I abandoned it >> due to the fact that Glibc source code is not >> > very easy to work with. >> > >> > I can upload it somewhere, not sure if there is any general interest in >> this kind of thing. I think current GRTE may >> > also be build-able with Clang (my fork was based on older GRTE which >> had unfinished patches to support Clang), though I >> > haven't had the time to look at that recently. >> > >> > I should add a huge disclaimer: this won't be easy and requires >> understanding the macro hell in glibc, GRTE relies on >> > some hacky uses of `_Pragma` to supplement for some macros otherwise >> not possible with Clang. Even if you do get it to >> > build I think it may be a waste of time to try and just implement the >> missing symbols in your case (or figure out why >> > they're not being exported). >> > >> > Thanks. >> > >> > On 22/12/2018 09:29, xuruobin via llvm-dev wrote: >> >> To whom it may concern, >> >> >> >> Is there a way to build glibc with clang/llvm? I’m working on >> enabling llvm-cov for my compiler which is a totally new arch with a libc.a >> built from newlib. I successfully built compiler-rt but when I typed the >> command ` clang++ --target=xxx -fprofile-instr-generate -fcoverage-mapping >> foo.cc -o foo`, the linker failed because of undefined reference to >> `mmap'/`ftruncate'/`mkdir'. I found these functions are supported by glibc >> but I cannot bulid glibc with clang/llvm(configure gave me an error “These >> critical programs are missing or too old: compiler”). So I want to know how >> can I compile glibc with clang/llvm or are there some WIP patches to help >> me with this requirement? >> >> >> >> Thanks, >> >> Ruobin. >> >> _______________________________________________ >> >> LLVM Developers mailing list >> >> llvm-dev at lists.llvm.org >> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >> > >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181224/da658e86/attachment.html>
xuruobin via llvm-dev
2018-Dec-25 07:52 UTC
[llvm-dev] 答复: How to compile glibc with clang/llvm?
Since I'm working on clang4.0.1, I cannot use GRTE. I will try to extract these syscalls from glibc source code, thanks anyway.> -----邮件原件----- > 发件人: Kristina Brooks [mailto:notstina at gmail.com] > 发送时间: 2018年12月23日 19:00 > 收件人: xuruobin <xuruobin at huawei.com> > 抄送: llvm-dev at lists.llvm.org > 主题: Re: [llvm-dev] How to compile glibc with clang/llvm? > > Hi. > > Actually from reading the README, it seems to imply that it can be built > with Clang 6.0.0 and above now, though it does incorporate a lot of patches > not > specific to Clang building so you will end up with them as well: > > ---------------------------------------------------------------------------- > BUILDING GRTE WITH CLANG > > GRTE v5 and later can also be built with clang and (optionally) lld. > LLVM support for GNU source code continues to evolve (as of June > 2018), so the process is less straightforward, and likely to change > from what is documented here. There are a number of glibc patches > that make this work, including additional configure options mentioned > below. > > The minimum version of clang is 6.0.0. If lld is to be used for linking, > it needs to be newer than 6.0.0. > > Configure: > > CC=path-to-llvm/clang CXX=path-to-llvm/clang++ \ > ../glibc/configure --disable-werror --with-clang --disable-float128 \ > --with-lld --with-default-link --disable-multi-arch --prefix=/something > ------------------------------------------------------------------------------ > > On 23/12/2018 02:51, Kristina Brooks wrote: > > Hi. > > > > I've managed to do it before, with a lot of patches to Glibc, as well as ld.so > and getting basic programs to start with > > it. However, a lot of tests did not pass and in general I abandoned it due to > the fact that Glibc source code is not > > very easy to work with. > > > > I can upload it somewhere, not sure if there is any general interest in this > kind of thing. I think current GRTE may > > also be build-able with Clang (my fork was based on older GRTE which had > unfinished patches to support Clang), though I > > haven't had the time to look at that recently. > > > > I should add a huge disclaimer: this won't be easy and requires > understanding the macro hell in glibc, GRTE relies on > > some hacky uses of `_Pragma` to supplement for some macros otherwise > not possible with Clang. Even if you do get it to > > build I think it may be a waste of time to try and just implement the missing > symbols in your case (or figure out why > > they're not being exported). > > > > Thanks. > > > > On 22/12/2018 09:29, xuruobin via llvm-dev wrote: > >> To whom it may concern, > >> > >> Is there a way to build glibc with clang/llvm? I’m working on enabling > llvm-cov for my compiler which is a totally new arch with a libc.a built from > newlib. I successfully built compiler-rt but when I typed the command ` > clang++ --target=xxx -fprofile-instr-generate -fcoverage-mapping foo.cc -o > foo`, the linker failed because of undefined reference to > `mmap'/`ftruncate'/`mkdir'. I found these functions are supported by glibc > but I cannot bulid glibc with clang/llvm(configure gave me an error “These > critical programs are missing or too old: compiler”). So I want to know how > can I compile glibc with clang/llvm or are there some WIP patches to help me > with this requirement? > >> > >> Thanks, > >> Ruobin. > >> _______________________________________________ > >> LLVM Developers mailing list > >> llvm-dev at lists.llvm.org > >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >> > >