@@ -63,10 +63,8 @@ IN THE SOFTWARE.
63
63
#endif // defined( _DEBUG ) || defined( _INTERNAL )
64
64
#if defined(IGC_VC_ENABLED)
65
65
#include " Frontend.h"
66
-
67
66
#if defined(_WIN32)
68
67
#include < Windows.h>
69
- #include < llvm/Support/ConvertUTF.h>
70
68
#include " inc/common/DriverStore.h"
71
69
#endif
72
70
#endif // defined(IGC_VC_ENABLED)
@@ -75,38 +73,6 @@ IN THE SOFTWARE.
75
73
76
74
#include < memory>
77
75
78
- #if defined(__linux__)
79
- #include < dlfcn.h>
80
- #else
81
- #include < Windows.h>
82
-
83
- static std::string encode_asA (const std::wstring& wstr) {
84
- if (wstr.empty ())
85
- return {};
86
- int inputSize = static_cast <int >(wstr.size ());
87
- int sizeNeeded = WideCharToMultiByte (CP_ACP, 0 , &wstr[0 ], (int )wstr.size (), NULL , 0 , NULL , NULL );
88
- if (sizeNeeded == 0 )
89
- return {};
90
- std::string strTo (sizeNeeded, 0 );
91
- if (WideCharToMultiByte (CP_ACP, 0 , &wstr[0 ], inputSize, &strTo[0 ], sizeNeeded, NULL , NULL ) == 0 )
92
- return {};
93
- return strTo;
94
- }
95
- static std::wstring encode_asW (const std::string& str) {
96
- if (str.empty ())
97
- return {};
98
- int inputSize = static_cast <int >(str.size ());
99
- int sizeNeeded = MultiByteToWideChar (CP_ACP, 0 , &str[0 ], inputSize, NULL , 0 );
100
- if (sizeNeeded == 0 )
101
- return {};
102
- std::wstring wstrTo (sizeNeeded, 0 );
103
- if (MultiByteToWideChar (CP_ACP, 0 , &str[0 ], inputSize, &wstrTo[0 ], sizeNeeded) == 0 )
104
- return {};
105
- return wstrTo;
106
- }
107
-
108
- #endif
109
-
110
76
namespace IGC {
111
77
112
78
OclTranslationOutputBase *
@@ -142,58 +108,6 @@ llvm::Optional<std::vector<char>> readBinaryFile(const std::string& fileName) {
142
108
143
109
#if defined(IGC_VC_ENABLED)
144
110
145
- static std::string detectCmIncludes (llvm::sys::DynamicLibrary &LibInfo) {
146
- #if defined(__linux__)
147
- #define GetFunctionNameAsStr (s ) ((void )s, #s);
148
- const char *SymName = GetFunctionNameAsStr (IntelCMClangFECompile);
149
- void *FAddr = LibInfo.getAddressOfSymbol (SymName);
150
- #undef GetFunctionNameAsStr
151
- // currently Linux does not require header detection facilities
152
-
153
- Dl_info DlInfo;
154
- if (!dladdr (FAddr, &DlInfo))
155
- return {};
156
-
157
- auto IncludeRoot = llvm::sys::path::parent_path (
158
- llvm::sys::path::parent_path (
159
- llvm::sys::path::parent_path (DlInfo.dli_fname )));
160
- llvm::SmallVector<char , 1024 > PathData (IncludeRoot.begin (),
161
- IncludeRoot.end ());
162
- #else
163
- (void )LibInfo;
164
- // Strictly speaking, FE name may not in the correct encoding.
165
- // But here we assume that it is ;).
166
- std::wstring FeName = encode_asW (CMFE_WRAPPER_NAME);
167
- HMODULE FE_LIB_HANDLER = GetModuleHandleW (FeName.c_str ());
168
- if (FE_LIB_HANDLER == NULL )
169
- return {};
170
-
171
- // this means that functions succeeded, but the path may be incomplete
172
- // won't bother figuring this out programmatically
173
- const size_t MAX_WINDOWS_PATH_LENGTH = 32767 ;
174
- std::vector<wchar_t > buffer (MAX_WINDOWS_PATH_LENGTH);
175
- // so portable... so usefull
176
- auto Res = GetModuleFileNameW (FE_LIB_HANDLER, buffer.data (), buffer.size ());
177
- if (Res == buffer.size ()) // don't want to mess with that - bail out
178
- return {};
179
- if (Res == 0 ) // if function indicates an error - bail out
180
- return {};
181
- buffer.push_back (0 ); // zero-terminate the data
182
- auto LibPath = encode_asA (std::wstring (buffer.data ()));
183
- auto ParentPath = llvm::sys::path::parent_path (LibPath).str ();
184
- llvm::SmallVector<char , MAX_PATH> PathData (ParentPath.begin (),
185
- ParentPath.end ());
186
- #endif
187
- llvm::sys::path::append (PathData, " include" , " cm" , " cm.h" );
188
- llvm::StringRef CMHeaderPath (PathData.begin (), PathData.size ());
189
- if (llvm::sys::fs::exists (CMHeaderPath)) {
190
- return llvm::sys::path::parent_path (
191
- llvm::sys::path::parent_path (CMHeaderPath))
192
- .str ();
193
- }
194
- return {};
195
- }
196
-
197
111
using InvocationInfo = IGC::AdaptorCM::Frontend::IDriverInvocation;
198
112
using PathT = llvm::SmallVector<char , 1024 >;
199
113
@@ -331,19 +245,6 @@ static std::vector<const char*>
331
245
result.push_back (stringSaver.save (" -march=" + cmfeDefaultArch).data ());
332
246
}
333
247
334
- llvm::StringRef FeIncludesPath;
335
- auto auxIncludes = llvm::sys::Process::GetEnv (" CM_INCLUDE_DIR" );
336
- if (auxIncludes) {
337
- FeIncludesPath = stringSaver.save (auxIncludes.getValue ());
338
- } else {
339
- auto IncludePath = detectCmIncludes (LibInfo);
340
- if (!IncludePath.empty ())
341
- FeIncludesPath = stringSaver.save (IncludePath);
342
- }
343
- if (!FeIncludesPath.empty ()) {
344
- result.push_back (stringSaver.save (" -isystem" ).data ());
345
- result.push_back (FeIncludesPath.data ());
346
- }
347
248
result.insert (result.end (), userArgs.begin (), userArgs.end ());
348
249
349
250
auto ExtraCMOpts = llvm::sys::Process::GetEnv (" IGC_ExtraCMOptions" );
0 commit comments