Page MenuHomePhabricator

[Driver] Support -muclibc / -mglibc command line options
ClosedPublic

Authored by atanasyan on Aug 5 2014, 8:34 AM.

Details

Summary

The uCLibc library supports multiple architectures. A couple of MIPS toolchains contains both uCLibc and glibc implementation so these options allow to select used C library. Initially -muclibc / -mglibc (as well as -mbionic) have been implemented in gcc.

Diff Detail

Event Timeline

atanasyan updated this revision to Diff 12196.Aug 5 2014, 8:34 AM
atanasyan retitled this revision from to [Driver] Support -muclibc / -mglibc command line options.
atanasyan updated this object.
atanasyan edited the test plan for this revision. (Show Details)
atanasyan added reviewers: rafael, chandlerc.
atanasyan added a subscriber: Unknown Object (MLST).
joerg added a subscriber: joerg.Aug 5 2014, 8:55 AM

Is there a good reason for not switching them via a single option with value, e.g. -mlibc=musl, -mlibc=glibc etc?

-muclibc / -mglibc come from gcc. I think we need to keep their names as-is for compatibility.

rafael edited edge metadata.Aug 11 2014, 11:27 AM

I tried the patch locally, but two tests fails:

Clang :: Driver/mips-cs.cpp
Clang :: Driver/mips-fsf.cpp

/home/espindola/llvm/clang/test/Driver/mips-cs.cpp:39:23: error: expected string not found in input
// CHECK-BE-UC-HF-32: "[[TC]]/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu/uclibc"

^

<stdin>:4:622: note: scanning from here
"/home/espindola/llvm/build/./bin/clang" "-cc1" "-triple" "mips--linux-gnu" "-S" "-disable-free" "-main-file-name" "mips-cs.cpp" "-mrelocation-model" "static" "-mdisable-fp-elim" "-fmath-errno" "-no-integrated-as" "-mconstructor-aliases" "-target-cpu" "mips32r2" "-target-feature" "-n64" "-target-feature" "+o32" "-target-abi" "o32" "-mfloat-abi" "hard" "-dwarf-column-info" "-resource-dir" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/backward" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/local/include" "-internal-isystem" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/include" "-fdeprecated-macro" "-fno-dwarf-directory-asm" "-fdebug-compilation-dir" "/home/espindola/llvm/build/tools/clang/test/Driver" "-ferror-limit" "19" "-fmessage-length" "0" "-mstackrealign" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" "/tmp/mips-cs-00c4ac.s" "-x" "c++" "/home/espindola/llvm/clang/test/Driver/mips-cs.cpp"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^

<stdin>:4:622: note: with variable "TC" equal to "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3"
"/home/espindola/llvm/build/./bin/clang" "-cc1" "-triple" "mips--linux-gnu" "-S" "-disable-free" "-main-file-name" "mips-cs.cpp" "-mrelocation-model" "static" "-mdisable-fp-elim" "-fmath-errno" "-no-integrated-as" "-mconstructor-aliases" "-target-cpu" "mips32r2" "-target-feature" "-n64" "-target-feature" "+o32" "-target-abi" "o32" "-mfloat-abi" "hard" "-dwarf-column-info" "-resource-dir" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/backward" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/local/include" "-internal-isystem" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/include" "-fdeprecated-macro" "-fno-dwarf-directory-asm" "-fdebug-compilation-dir" "/home/espindola/llvm/build/tools/clang/test/Driver" "-ferror-limit" "19" "-fmessage-length" "0" "-mstackrealign" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" "/tmp/mips-cs-00c4ac.s" "-x" "c++" "/home/espindola/llvm/clang/test/Driver/mips-cs.cpp"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ^

<stdin>:4:697: note: possible intended match here
"/home/espindola/llvm/build/./bin/clang" "-cc1" "-triple" "mips--linux-gnu" "-S" "-disable-free" "-main-file-name" "mips-cs.cpp" "-mrelocation-model" "static" "-mdisable-fp-elim" "-fmath-errno" "-no-integrated-as" "-mconstructor-aliases" "-target-cpu" "mips32r2" "-target-feature" "-n64" "-target-feature" "+o32" "-target-abi" "o32" "-mfloat-abi" "hard" "-dwarf-column-info" "-resource-dir" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/mips-linux-gnu" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/include/c++/4.6.3/backward" "-internal-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/local/include" "-internal-isystem" "/home/espindola/llvm/build/./bin/../lib/clang/3.6.0/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/include" "-internal-externc-isystem" "/home/espindola/llvm/clang/test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/../../../../mips-linux-gnu/libc/usr/include" "-fdeprecated-macro" "-fno-dwarf-directory-asm" "-fdebug-compilation-dir" "/home/espindola/llvm/build/tools/clang/test/Driver" "-ferror-limit" "19" "-fmessage-length" "0" "-mstackrealign" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" "/tmp/mips-cs-00c4ac.s" "-x" "c++" "/home/espindola/llvm/clang/test/Driver/mips-cs.cpp"

Hmm, could you check that changes (new files) in the test/Driver/Inputs/mips_cs_tree and test/Driver/Inputs/mips_fsf_tree directories applied correctly? I ran arc patch D4790 command, rebuilt the Clang, ran the Clang's test suite and did not get any errors.

The patch you can download from the Phabricator site using the "Download Raw Diff" link is reduced. Probably it is the Phabricator's bug. This file does not contain any new .o files. This page has paths like test/Driver/Inputs/mips_cs_tree/lib/gcc/mips-linux-gnu/4.6.3/uclibc/soft-float/crtbegin.o. The D4790.diff does not have such files.

I create another patch and attach it to this message.

rafael accepted this revision.Aug 12 2014, 5:14 PM
rafael edited edge metadata.

LGTM with a nit.

lib/Driver/ToolChains.cpp
1739

Since you are calling str() anyway, it might be cleaner to construct it with

String S = InstallDir + "/../../../../sysroot/";
if (...)
  S +=
 else
   S +=
This revision is now accepted and ready to land.Aug 12 2014, 5:14 PM
atanasyan closed this revision.Aug 13 2014, 7:43 AM

Thanks for review.

Closed by commit rL215552.