{"action":"created","issue":{"url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/98","labels_url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/98/labels{/name}","comments_url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/98/comments","events_url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/98/events","html_url":"https://github.com/riscv/riscv-gnu-toolchain/issues/98","id":114360302,"number":98,"title":"No libgcc.a for -m32 -march=RV32I","user":{"login":"cliffordwolf","id":619764,"avatar_url":"https://avatars.githubusercontent.com/u/619764?v=3","gravatar_id":"","url":"https://api.github.com/users/cliffordwolf","html_url":"https://github.com/cliffordwolf","followers_url":"https://api.github.com/users/cliffordwolf/followers","following_url":"https://api.github.com/users/cliffordwolf/following{/other_user}","gists_url":"https://api.github.com/users/cliffordwolf/gists{/gist_id}","starred_url":"https://api.github.com/users/cliffordwolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cliffordwolf/subscriptions","organizations_url":"https://api.github.com/users/cliffordwolf/orgs","repos_url":"https://api.github.com/users/cliffordwolf/repos","events_url":"https://api.github.com/users/cliffordwolf/events{/privacy}","received_events_url":"https://api.github.com/users/cliffordwolf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-30T21:36:41Z","updated_at":"2015-12-09T14:12:20Z","closed_at":null,"body":"I used to be able to create RV32I binaries that use symbols such as `__mulsi3` from libgcc like this:\r\n\r\n    riscv64-unknown-elf-gcc -c -m32 -march=RV32I -ffreestanding -nostdlib test.c\r\n    riscv64-unknown-elf-gcc -m32 -march=RV32I -ffreestanding -nostdlib -o test.elf test.o -lgcc\r\n\r\nHere is an example `test.c` that wants to use `__mulsi3`:\r\n\r\n    #include <stdint.h>\r\n    \r\n    void _start(uint32_t a, uint32_t b)\r\n    {\r\n        uint64_t au = a, bu = b;\r\n        int64_t as = (int32_t)a, bs = (int32_t)b;\r\n        uint32_t s_mul, s_mulh, s_mulhsu, s_mulhu;\r\n    \r\n        s_mul = a * b;\r\n        s_mulh = (as * bs) >> 32;\r\n        s_mulhsu = (as * bu) >> 32;\r\n        s_mulhu = (au * bu) >> 32;\r\n    \r\n        if (s_mul == s_mulh || s_mulhsu == s_mulhu)\r\n            __asm__ volatile (\"sbreak\");\r\n    }\r\n\r\nWith git head of riscv-gnu-toolchain (1ad4bfc) I can't do that anymore and get the following error:\r\n\r\n    $ riscv64-unknown-elf-gcc -m32 -march=RV32I -ffreestanding -nostdlib -o test.elf test.o -lgcc\r\n    /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/../../../../riscv64-unknown-elf/bin/ld: /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/libgcc.a(mul.o): ABI is incompatible with that of the selected emulation\r\n    /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/libgcc.a(mul.o)\r\n    test.o: In function `_start':\r\n    test.c:(.text+0x70): undefined reference to `__mulsi3'\r\n    collect2: error: ld returned 1 exit status\r\n\r\nThere used to be a `/opt/riscv/lib/gcc/riscv64-unknown-elf/5.2.0/32/libgcc.a`, but it's not there anymore. Do I need to build multilib support for this, even when I don't use any libraries but just want full C language support for integer ops? This seems a little bit odd to me.."},"comment":{"url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/comments/163248894","html_url":"https://github.com/riscv/riscv-gnu-toolchain/issues/98#issuecomment-163248894","issue_url":"https://api.github.com/repos/riscv/riscv-gnu-toolchain/issues/98","id":163248894,"user":{"login":"heshamelmatary","id":1679930,"avatar_url":"https://avatars.githubusercontent.com/u/1679930?v=3","gravatar_id":"","url":"https://api.github.com/users/heshamelmatary","html_url":"https://github.com/heshamelmatary","followers_url":"https://api.github.com/users/heshamelmatary/followers","following_url":"https://api.github.com/users/heshamelmatary/following{/other_user}","gists_url":"https://api.github.com/users/heshamelmatary/gists{/gist_id}","starred_url":"https://api.github.com/users/heshamelmatary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heshamelmatary/subscriptions","organizations_url":"https://api.github.com/users/heshamelmatary/orgs","repos_url":"https://api.github.com/users/heshamelmatary/repos","events_url":"https://api.github.com/users/heshamelmatary/events{/privacy}","received_events_url":"https://api.github.com/users/heshamelmatary/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T14:12:20Z","updated_at":"2015-12-09T14:12:20Z","body":"Any updates regarding this issue? \r\n\r\nI am also trying to build 32-bit version of gcc-newlib, but I am getting some error when compiling gcc directly from the src subdirectory (not from the riscv-gnu-toolchain top-level):\r\n\r\n\"../../../../../newlib/libc/stdlib/dtoa.c: In function '_dtoa_r':\r\n../../../../../newlib/libc/stdlib/dtoa.c:862:1: error: insn does not satisfy its constraints:\r\n }\r\n ^\r\n(insn 69 68 215 2 (set (reg/v:DF 28 t3 [orig:396 _d ] [396])\r\n        (reg:DF 44 fa2 [ _d ])) ../../../../../newlib/libc/stdlib/dtoa.c:189 142 {*movdf_hardfloat_rv32}\r\n     (nil))\r\n../../../../../newlib/libc/stdlib/dtoa.c:862:1: internal compiler error: in extract_constrain_insn, at recog.c:2246\""}}