<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, May 16, 2013 at 11:50 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
On May 16, 2013, at 11:32 AM, Michael Sartain <<a href="mailto:mikesart@valvesoftware.com">mikesart@valvesoftware.com</a>> wrote:<br>
<br>
> On Thu, May 16, 2013 at 10:39 AM, Malea, Daniel <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a>> wrote:<br>
> If we only support one ModuleSpec on Linux, maybe add:<br>
><br>
> assert(num_specs == 1 && "Linux plugin supports only a single<br>
> architecture");<br>
><br>
> Yeah, that makes me feel more comfortable with that "== 1" check. It's in.<br>
><br>
> I ran into an issue where TargetList::CreateTarget() was failing because it's calling ObjectFile::GetModuleSpecifications() and getting back x86_64 / UnknownVendor / UnknownOS and is expecting to find the Linux for the OS when it calls IsCompatibleMatch().<br>


><br>
> So I modified ArchSpec::SetArchitecture() to set the Linux OS using an ifdef in ArchSpec.cpp. Is this the best way to do this?<br>
<br>
</div>No, I would do this by modifying all the architectures in ModuleSpec objects that are returned from ObjectFile::GetModuleSpecifications() inside GetELFProcessCPUType().<br></blockquote></div><br></div><div class="gmail_extra">

Sorry I wasn't clear - this issue has nothing to do with the code in Linux/Host.cpp. It's showing up because we've now implemented ObjectFileELF::GetModuleSpecifications().<br><br>It's returning x86_64 / UnknownVendor / UnknownOS for this target I'm trying to debug where it used to return nothing. Ie, invalid arch.<br>

<br></div><div class="gmail_extra">So in PlatformLinux.cpp, we are now running the exe_arch.IsValid() block down below (used to take the else clause).<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">
m_arch in module_spec is:<br>
</div><div class="gmail_extra">    Arch = llvm::Triple::x86_64,<br>    Vendor = llvm::Triple::UnknownVendor,<br>    OS = llvm::Triple::Linux,   <br>    Environment = llvm::Triple::GNU<br></div><div class="gmail_extra">exe_arch is:<br>

    Arch = llvm::Triple::x86_64,<br>    Vendor = llvm::Triple::UnknownVendor,<br>    OS = llvm::Triple::UnknownOS,<br>    Environment = llvm::Triple::UnknownEnvironment<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">

ModuleList::GetShareModule() fails and reports my exe doesn't contain "x86_64". Modifying the code in ArchSpec to return Linux isn't the correct solution, but what is? Something local here where if OS is Unknown we match any OS?<br>

<br></div><div class="gmail_extra">Thanks.<br></div><div class="gmail_extra"></div><div class="gmail_extra"></div><div class="gmail_extra"><br></div>    if (error.Success())<br>    {<br>        ModuleSpec module_spec (resolved_exe_file, exe_arch);<br>

        if (exe_arch.IsValid())<br>        {<br>            error = ModuleList::GetSharedModule (module_spec, <br>                                                 exe_module_sp, <br>                                                 NULL, <br>

                                                 NULL,<br>                                                 NULL);<br>        <br>            // TODO find out why exe_module_sp might be NULL            <br>            if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)<br>

            {<br>                exe_module_sp.reset();<br>                error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",<br>                                                exe_file.GetPath().c_str(),<br>

                                                exe_arch.GetArchitectureName());<br>            }<br>        }<br>        else<br>        {<br>            // No valid architecture was specified, ask the platform for<br>            // the architectures that we should be using (in the correct order)<br>

            // and see if we can find a match that way<br>            StreamString arch_names;<br>            for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)<br>            {<br>

                error = ModuleList::GetSharedModule (module_spec, <br>                                                     exe_module_sp, <br>                                                     NULL, <br>                                                     NULL,<br>

                                                     NULL);<br>                // Did we find an executable using one of the <br>                if (error.Success())<br>                {<br>                    if (exe_module_sp && exe_module_sp->GetObjectFile())<br>

                        break;<br>                    else<br>                        error.SetErrorToGenericError();<br>                }<br>                <br>                if (idx > 0)<br>                    arch_names.PutCString (", ");<br>

                arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());<br>            }<br>            <br>            if (error.Fail() || !exe_module_sp)<br>            {<br>                error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",<br>

                                                exe_file.GetPath().c_str(),<br>                                                GetPluginName().GetCString(),<br>                                                arch_names.GetString().c_str());<br>

            }<br>        }<br>    }<br><br></div>