diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2153,6 +2153,7 @@ def mthreads : Joined<["-"], "mthreads">, Group, Flags<[DriverOption]>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group; def mmcu_EQ : Joined<["-"], "mmcu=">, Group; +def msim : Flag<["-"], "msim">, Group; def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group; def mfix_and_continue : Flag<["-"], "mfix-and-continue">, Group; def mieee_fp : Flag<["-"], "mieee-fp">, Group; @@ -2233,9 +2234,9 @@ def mno_lvi_cfi : Flag<["-"], "mno-lvi-cfi">, Group, Flags<[CoreOption,DriverOption]>, HelpText<"Disable control-flow mitigations for Load Value Injection (LVI)">; -def mrelax : Flag<["-"], "mrelax">, Group, +def mrelax : Flag<["-"], "mrelax">, Group, HelpText<"Enable linker relaxation">; -def mno_relax : Flag<["-"], "mno-relax">, Group, +def mno_relax : Flag<["-"], "mno-relax">, Group, HelpText<"Disable linker relaxation">; def msmall_data_limit_EQ : Joined<["-"], "msmall-data-limit=">, Group, Alias, diff --git a/clang/lib/Basic/Targets/MSP430.cpp b/clang/lib/Basic/Targets/MSP430.cpp --- a/clang/lib/Basic/Targets/MSP430.cpp +++ b/clang/lib/Basic/Targets/MSP430.cpp @@ -29,5 +29,6 @@ MacroBuilder &Builder) const { Builder.defineMacro("MSP430"); Builder.defineMacro("__MSP430__"); + Builder.defineMacro("__ELF__"); // FIXME: defines for different 'flavours' of MCU } diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -1505,15 +1505,21 @@ StringRef Path, const ArgList &Args, DetectedMultilibs &Result) { FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS()); - Multilib MSP430Multilib = makeMultilib("/430"); + Multilib WithoutExceptions = makeMultilib("/430").flag("-exceptions"); + Multilib WithExceptions = makeMultilib("/430/exceptions").flag("+exceptions"); + // FIXME: when clang starts to support msp430x ISA additional logic // to select between multilib must be implemented // Multilib MSP430xMultilib = makeMultilib("/large"); - Result.Multilibs.push_back(MSP430Multilib); + Result.Multilibs.push_back(WithoutExceptions); + Result.Multilibs.push_back(WithExceptions); Result.Multilibs.FilterOut(NonExistent); Multilib::flags_list Flags; + addMultilibFlag(Args.hasFlag(options::OPT_fexceptions, + options::OPT_fno_exceptions, false), + "exceptions", Flags); if (Result.Multilibs.select(Flags, Result.SelectedMultilib)) return true; diff --git a/clang/lib/Driver/ToolChains/MSP430.h b/clang/lib/Driver/ToolChains/MSP430.h --- a/clang/lib/Driver/ToolChains/MSP430.h +++ b/clang/lib/Driver/ToolChains/MSP430.h @@ -40,6 +40,11 @@ bool isPIEDefault() const override { return false; } bool isPICDefaultForced() const override { return true; } + UnwindLibType + GetUnwindLibType(const llvm::opt::ArgList &Args) const override { + return UNW_None; + } + protected: Tool *buildLinker() const override; @@ -62,6 +67,14 @@ const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override; + +private: + void AddStartFiles(bool UseExceptions, const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + void AddDefaultLibs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + void AddEndFiles(bool UseExceptions, const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; }; void getMSP430TargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp --- a/clang/lib/Driver/ToolChains/MSP430.cpp +++ b/clang/lib/Driver/ToolChains/MSP430.cpp @@ -128,7 +128,7 @@ } SmallString<128> SysRootDir(computeSysRoot()); - llvm::sys::path::append(SysRootDir, "lib", MultilibSuf); + llvm::sys::path::append(SysRootDir, "msp430-elf", "lib", MultilibSuf); addPathIfExists(D, SysRootDir, getFilePaths()); } @@ -138,10 +138,9 @@ SmallString<128> Dir; if (GCCInstallation.isValid()) - llvm::sys::path::append(Dir, GCCInstallation.getParentLibPath(), "..", - GCCInstallation.getTriple().str()); + llvm::sys::path::append(Dir, GCCInstallation.getParentLibPath(), ".."); else - llvm::sys::path::append(Dir, getDriver().Dir, "..", getTriple().str()); + llvm::sys::path::append(Dir, getDriver().Dir, ".."); return std::string(Dir.str()); } @@ -180,6 +179,77 @@ return new tools::msp430::Linker(*this); } +void msp430::Linker::AddStartFiles(bool UseExceptions, const ArgList &Args, + ArgStringList &CmdArgs) const { + const ToolChain &ToolChain = getToolChain(); + + const char *crt0 = Args.hasArg(options::OPT_pg) ? "gcrt0.o" : "crt0.o"; + CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt0))); + const char *crtbegin = UseExceptions ? "crtbegin.o" : "crtbegin_no_eh.o"; + CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin))); +} + +void msp430::Linker::AddDefaultLibs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const { + const ToolChain &ToolChain = getToolChain(); + const Driver &D = ToolChain.getDriver(); + + AddRunTimeLibs(ToolChain, D, CmdArgs, Args); + CmdArgs.push_back("--start-group"); + CmdArgs.push_back(Args.MakeArgString(getHWMultLib(Args))); + CmdArgs.push_back("-lc"); + AddRunTimeLibs(ToolChain, D, CmdArgs, Args); + CmdArgs.push_back("-lcrt"); + + if (Args.hasArg(options::OPT_msim)) { + CmdArgs.push_back("-lsim"); + CmdArgs.push_back("--undefined=__crt0_call_exit"); + } else + CmdArgs.push_back("-lnosys"); + + CmdArgs.push_back("--end-group"); + AddRunTimeLibs(ToolChain, D, CmdArgs, Args); +} + +void msp430::Linker::AddEndFiles(bool UseExceptions, const ArgList &Args, + ArgStringList &CmdArgs) const { + const ToolChain &ToolChain = getToolChain(); + const Driver &D = ToolChain.getDriver(); + + const char *crtend = UseExceptions ? "crtend.o" : "crtend_no_eh.o"; + CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend))); + AddRunTimeLibs(ToolChain, D, CmdArgs, Args); +} + +static void AddSspArgs(const ArgList &Args, ArgStringList &CmdArgs) { + Arg *SspFlag = Args.getLastArg(options::OPT_fstack_protector, + options::OPT_fstack_protector_all, + options::OPT_fstack_protector_strong); + + if (SspFlag && + !SspFlag->getOption().matches(options::OPT_fno_stack_protector)) { + CmdArgs.push_back("-lssp_noshared"); + CmdArgs.push_back("-lssp"); + } +} + +static void AddImplicitLinkerScript(const std::string SysRoot, + const ArgList &Args, + ArgStringList &CmdArgs) { + if (!Args.hasArg(options::OPT_T)) { + if (Args.hasArg(options::OPT_msim)) { + CmdArgs.push_back("-Tmsp430-sim.ld"); + } else if (const Arg *MCUArg = Args.getLastArg(options::OPT_mmcu_EQ)) { + SmallString<128> MCULinkerScriptPath(SysRoot); + llvm::sys::path::append(MCULinkerScriptPath, "include"); + // -L because .ld INCLUDEs _symbols.ld + CmdArgs.push_back(Args.MakeArgString("-L" + MCULinkerScriptPath)); + CmdArgs.push_back( + Args.MakeArgString("-T" + StringRef(MCUArg->getValue()) + ".ld")); + } + } +} + void msp430::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, @@ -189,44 +259,43 @@ const Driver &D = ToolChain.getDriver(); std::string Linker = ToolChain.GetProgramPath(getShortName()); ArgStringList CmdArgs; + bool UseExceptions = Args.hasFlag(options::OPT_fexceptions, + options::OPT_fno_exceptions, false); + bool UseStartAndEndFiles = + !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles); - if (!D.SysRoot.empty()) - CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); - - Args.AddAllArgs(CmdArgs, options::OPT_L); - ToolChain.AddFilePathLibArgs(Args, CmdArgs); + if (Args.hasArg(options::OPT_mrelax)) + CmdArgs.push_back("--relax"); + if (!Args.hasArg(options::OPT_r, options::OPT_g_Group)) + CmdArgs.push_back("--gc-sections"); - if (!Args.hasArg(options::OPT_T)) { - if (const Arg *MCUArg = Args.getLastArg(options::OPT_mmcu_EQ)) - CmdArgs.push_back( - Args.MakeArgString("-T" + StringRef(MCUArg->getValue()) + ".ld")); - } else { - Args.AddAllArgs(CmdArgs, options::OPT_T); - } + Args.AddAllArgs(CmdArgs, { + options::OPT_o, options::OPT_e, options::OPT_n, + options::OPT_r, options::OPT_s, options::OPT_t, + options::OPT_u, options::OPT_z, + }); - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o"))); - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o"))); - } + if (UseStartAndEndFiles) + AddStartFiles(UseExceptions, Args, CmdArgs); + Args.AddAllArgs(CmdArgs, options::OPT_L); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); - CmdArgs.push_back("--start-group"); - CmdArgs.push_back(Args.MakeArgString(getHWMultLib(Args))); - CmdArgs.push_back("-lgcc"); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { - CmdArgs.push_back("-lc"); - CmdArgs.push_back("-lcrt"); - CmdArgs.push_back("-lnosys"); + AddSspArgs(Args, CmdArgs); + AddDefaultLibs(Args, CmdArgs); + AddImplicitLinkerScript(D.SysRoot, Args, CmdArgs); } - CmdArgs.push_back("--end-group"); - if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o"))); - CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o"))); - } + if (UseStartAndEndFiles) + AddEndFiles(UseExceptions, Args, CmdArgs); + CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); + + Args.AddAllArgs(CmdArgs, options::OPT_T); + C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Linker), CmdArgs, Inputs)); } diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o rename from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o rename to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o rename from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o rename to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o rename from clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o rename to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o rename from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o rename to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o copy from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o copy to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o diff --git a/clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o b/clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o rename from clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o rename to clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o diff --git a/clang/test/Driver/msp430-toolchain.c b/clang/test/Driver/msp430-toolchain.c --- a/clang/test/Driver/msp430-toolchain.c +++ b/clang/test/Driver/msp430-toolchain.c @@ -1,78 +1,231 @@ -// A basic clang -cc1 command-line, and simple environment check. +// Tests for the toolchain description for msp430-gcc +// Splitting some tests into POS and NEG parts so the latter can validate +// output fragments as large as possible for absence of some text. + +// Tests for passing flags to msp430-elf-ld (not file-related) + + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" 2>&1 \ +// RUN: | FileCheck -check-prefix=DEFAULT-POS %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=CC1 %s -// CC1: clang{{.*}} "-cc1" "-triple" "msp430" +// RUN: | FileCheck -check-prefix=DEFAULT-NEG %s +// DEFAULT-POS: clang{{.*}} "-cc1" "-triple" "msp430" +// DEFAULT-POS: "{{.*}}msp430-elf-ld" +// DEFAULT-POS: "--gc-sections" +// DEFAULT-NEG-NOT: "--relax" + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -r 2>&1 | FileCheck -check-prefix=NO-GC-SECTIONS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -g 2>&1 | FileCheck -check-prefix=NO-GC-SECTIONS %s +// NO-GC-SECTIONS: clang{{.*}} "-cc1" "-triple" "msp430" +// NO-GC-SECTIONS-NOT: "--gc-sections" + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -Wl,--some-linker-arg 2>&1 | FileCheck -check-prefix=WL-ARG %s +// WL-ARG: "{{.*}}msp430-elf-ld" +// WL-ARG: "--some-linker-arg" + +// Trivially mapped options: arbitrarily split into two disjoint groups +// to check both "on"/present and "off"/absent state (when appropriate). + + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -o /tmp/test.elf -r -t -z muldefs -mrelax 2>&1 | FileCheck -check-prefix=MISC-FLAGS-1-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -o /tmp/test.elf -r -t -z muldefs -mrelax 2>&1 | FileCheck -check-prefix=MISC-FLAGS-1-NEG %s +// MISC-FLAGS-1-POS: "{{.*}}msp430-elf-ld" +// MISC-FLAGS-1-POS: "--relax" +// MISC-FLAGS-1-POS: "-o" "/tmp/test.elf" "-r" "-t" "-z" "muldefs" +// MISC-FLAGS-1-NEG: "{{.*}}msp430-elf-ld" +// MISC-FLAGS-1-NEG-NOT: "-e{{.*}}" +// MISC-FLAGS-1-NEG-NOT: "-s" +// MISC-FLAGS-1-NEG-NOT: "-u" + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -e EntryPoint -s -u __undef 2>&1 | FileCheck -check-prefix=MISC-FLAGS-2-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 --sysroot="" \ +// RUN: -e EntryPoint -s -u __undef 2>&1 | FileCheck -check-prefix=MISC-FLAGS-2-NEG %s +// MISC-FLAGS-2-POS: "{{.*}}msp430-elf-ld" +// MISC-FLAGS-2-POS: "-e" "EntryPoint" "-s" "-u" "__undef" +// MISC-FLAGS-2-NEG: "{{.*}}msp430-elf-ld" +// MISC-FLAGS-2-NEG-NOT: "-r" +// MISC-FLAGS-2-NEG-NOT: "-t" +// MISC-FLAGS-2-NEG-NOT: "-z" +// MISC-FLAGS-2-NEG-NOT: "--relax" + + +// Tests for -nostdlib, -nostartfiles, -nodefaultfiles and -f(no-)exceptions + + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-DEFAULT-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \ +// RUN: --gcc-toolchain="%S/Inputs/basic_msp430_tree" --sysroot="" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-DEFAULT-GCC-TOOLCHAIN %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-DEFAULT-NEG %s +// LIBS-DEFAULT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-DEFAULT-POS: "{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" +// LIBS-DEFAULT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtbegin_no_eh.o" +// LIBS-DEFAULT-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-DEFAULT-POS: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-DEFAULT-POS: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lnosys" "--end-group" "-lgcc" +// LIBS-DEFAULT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtend_no_eh.o" "-lgcc" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtbegin_no_eh.o" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lnosys" "--end-group" +// LIBS-DEFAULT-GCC-TOOLCHAIN: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtend_no_eh.o" "-lgcc" +// LIBS-DEFAULT-NEG-NOT: gcrt0.o +// LIBS-DEFAULT-NEG-NOT: crtbegin.o +// LIBS-DEFAULT-NEG-NOT: -lssp_nonshared +// LIBS-DEFAULT-NEG-NOT: -lssp +// LIBS-DEFAULT-NEG-NOT: crtend.o +// LIBS-DEFAULT-NEG-NOT: /exceptions + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-EXC-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -fexceptions \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-EXC-NEG %s +// LIBS-EXC-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-EXC-POS: "{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430/exceptions{{/|\\\\}}crt0.o" +// LIBS-EXC-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions{{/|\\\\}}crtbegin.o" +// LIBS-EXC-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions" +// LIBS-EXC-POS: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430/exceptions" +// LIBS-EXC-POS: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lnosys" "--end-group" +// LIBS-EXC-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions{{/|\\\\}}crtend.o" "-lgcc" +// LIBS-EXC-NEG-NOT: "{{.*}}/430" +// LIBS-EXC-NEG-NOT: "{{.*}}430/crt{{.*}}" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 \ -// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430 %s - -// MSP430: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" -// MSP430: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430" -// MSP430: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" -// MSP430: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" -// MSP430: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|\\\\}}crtbegin.o" -// MSP430: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" "--end-group" -// MSP430: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|\\\\}}crtend.o" -// MSP430: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crtn.o" +// RUN: -fstack-protector --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-SSP %s +// LIBS-SSP: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-SSP: "{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" +// LIBS-SSP: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtbegin_no_eh.o" +// LIBS-SSP: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-SSP: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-SSP: "-lssp_noshared" "-lssp" +// LIBS-SSP: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lnosys" "--end-group" +// LIBS-SSP: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtend_no_eh.o" "-lgcc" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \ -// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-NO-DFT-LIB %s - -// MSP430-NO-DFT-LIB: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" -// MSP430-NO-DFT-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430" -// MSP430-NO-DFT-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" -// MSP430-NO-DFT-LIB: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" -// MSP430-NO-DFT-LIB: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|\\\\}}crtbegin.o" -// MSP430-NO-DFT-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group" -// MSP430-NO-DFT-LIB: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430{{/|\\\\}}crtend.o" -// MSP430-NO-DFT-LIB: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crtn.o" +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-NO-DFT-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nodefaultlibs \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-NO-DFT-NEG %s +// LIBS-NO-DFT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-NO-DFT-POS: "{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430{{/|\\\\}}crt0.o" +// LIBS-NO-DFT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtbegin_no_eh.o" +// LIBS-NO-DFT-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-NO-DFT-POS: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-NO-DFT-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430{{/|\\\\}}crtend_no_eh.o" "-lgcc" +// LIBS-NO-DFT-NEG-NOT: "-lc" +// LIBS-NO-DFT-NEG-NOT: "-lcrt" +// LIBS-NO-DFT-NEG-NOT: "-lnosys" +// LIBS-NO-DFT-NEG-NOT: "--start-group" +// LIBS-NO-DFT-NEG-NOT: "--end-group" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \ -// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-NO-START %s - -// MSP430-NO-START: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" -// MSP430-NO-START: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430" -// MSP430-NO-START: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" -// MSP430-NO-START: "--start-group" "-lmul_none" "-lgcc" "-lc" "-lcrt" "-lnosys" "--end-group" +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-NO-START-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostartfiles \ +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-NO-START-NEG %s +// LIBS-NO-START-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-NO-START-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-NO-START-POS: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-NO-START-POS: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lnosys" "--end-group" +// LIBS-NO-START-NEG-NOT: crt0.o +// LIBS-NO-START-NEG-NOT: crtbegin +// LIBS-NO-START-NEG-NOT: crtend // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -nostdlib \ -// RUN: --gcc-toolchain=%S/Inputs/basic_msp430_tree --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-NO-STD-LIB %s - -// MSP430-NO-STD-LIB: "{{.*}}Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" -// MSP430-NO-STD-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430" -// MSP430-NO-STD-LIB: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/../../..{{/|\\\\}}..{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" -// MSP430-NO-STD-LIB: "--start-group" "-lmul_none" "-lgcc" "--end-group" +// RUN: --sysroot="%S/Inputs/basic_msp430_tree" 2>&1 \ +// RUN: | FileCheck -check-prefix=LIBS-NO-STD-POS %s +// LIBS-NO-STD-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LIBS-NO-STD-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// LIBS-NO-STD-POS: "-L{{.*}}/Inputs/basic_msp430_tree{{/|\\\\}}msp430-elf{{/|\\\\}}lib/430" +// LIBS-NO-STD-NEG-NOT: crt0.o +// LIBS-NO-STD-NEG-NOT: crtbegin +// LIBS-NO-STD-NEG-NOT: crtend +// LIBS-NO-STD-NEG-NOT: "-lc" +// LIBS-NO-STD-NEG-NOT: "-lcrt" +// LIBS-NO-STD-NEG-NOT: "-lnosys" +// LIBS-NO-STD-NEG-NOT: "--start-group" +// LIBS-NO-STD-NEG-NOT: "--end-group" + + +// Test for linker script autodiscovery + + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 \ +// RUN: --sysroot=%S/Inputs/basic_msp430_tree 2>&1 \ +// RUN: | FileCheck -check-prefix=LD-SCRIPT %s +// LD-SCRIPT: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// LD-SCRIPT: "-L{{.*}}/Inputs/basic_msp430_tree/include" +// LD-SCRIPT: "-Tmsp430g2553.ld" + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 \ +// RUN: --sysroot=%S/Inputs/basic_msp430_tree \ +// RUN: -T custom_script.ld 2>&1 \ +// RUN: | FileCheck -check-prefix=CUSTOM-LD-SCRIPT %s +// CUSTOM-LD-SCRIPT: "{{.*}}msp430-elf-ld" +// CUSTOM-LD_SCRIPT-NOT: "-Tmsp430g2553.ld" +// CUSTOM-LD-SCRIPT: "-T" "custom_script.ld" +// CUSTOM-LD_SCRIPT-NOT: "-Tmsp430g2553.ld" + +// Test for compiling for simulator + +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 \ +// RUN: -msim --sysroot=%S/Inputs/basic_msp430_tree 2>&1 \ +// RUN: | FileCheck -check-prefix=SIMULATOR-POS %s +// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430g2553 \ +// RUN: -msim --sysroot=%S/Inputs/basic_msp430_tree 2>&1 \ +// RUN: | FileCheck -check-prefix=SIMULATOR-NEG %s +// SIMULATOR-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/../../..{{/|\\\\}}..{{/|\\\\}}bin{{/|\\\\}}msp430-elf-ld" +// SIMULATOR-POS: "{{.*}}/Inputs/basic_msp430_tree/msp430-elf/lib/430/crt0.o" +// SIMULATOR-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o" +// SIMULATOR-POS: "-L{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430" +// SIMULATOR-POS: "-L{{.*}}/Inputs/basic_msp430_tree/msp430-elf/lib/430" +// SIMULATOR-POS: "-lgcc" "--start-group" "-lmul_none" "-lc" "-lgcc" "-lcrt" "-lsim" "--undefined=__crt0_call_exit" "--end-group" +// SIMULATOR-POS: "-Tmsp430-sim.ld" +// SIMULATOR-POS: "{{.*}}/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o" "-lgcc" +// SIMULATOR-NEG-NOT: "-lnosys" + +// Tests for HWMult // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s +// RUN: | FileCheck -check-prefix=HWMult-16BIT %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f147 -mhwmult=auto --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s +// RUN: | FileCheck -check-prefix=HWMult-16BIT %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=16bit --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-16BIT %s - -// MSP430-HWMult-16BIT: "--start-group" "-lmul_16" +// RUN: | FileCheck -check-prefix=HWMult-16BIT %s +// HWMult-16BIT: "--start-group" "-lmul_16" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s +// RUN: | FileCheck -check-prefix=HWMult-32BIT %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f4783 -mhwmult=auto --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s +// RUN: | FileCheck -check-prefix=HWMult-32BIT %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=32bit --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-32BIT %s - -// MSP430-HWMult-32BIT: "--start-group" "-lmul_32" +// RUN: | FileCheck -check-prefix=HWMult-32BIT %s +// HWMult-32BIT: "--start-group" "-lmul_32" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-F5 %s -// MSP430-HWMult-F5: "--start-group" "-lmul_f5" +// RUN: | FileCheck -check-prefix=HWMult-F5 %s +// HWMult-F5: "--start-group" "-lmul_f5" // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-NONE %s +// RUN: | FileCheck -check-prefix=HWMult-NONE %s // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=none -mmcu=msp430f4783 --sysroot="" 2>&1 \ -// RUN: | FileCheck -check-prefix=MSP430-HWMult-NONE %s - -// MSP430-HWMult-NONE: "--start-group" "-lmul_none" +// RUN: | FileCheck -check-prefix=HWMult-NONE %s +// HWMult-NONE: "--start-group" "-lmul_none"