@@ -321,20 +321,15 @@ static void adjustArgs(const InputArgList &UserArgList,
321321 DAL.AddJoinedArg (
322322 nullptr , OptTable.getOption (OPT_resource_dir_EQ),
323323 (DPCPPRoot + " /lib/clang/" + Twine (CLANG_VERSION_MAJOR)).str ());
324- for (auto *Arg : UserArgList) {
325- DAL.append (Arg);
326- }
327- // Remove args that will trigger an unused command line argument warning for
328- // the FrontendAction invocation, but are handled later (e.g. during device
329- // linking).
330- DAL.eraseArg (OPT_fsycl_device_lib_EQ);
331- DAL.eraseArg (OPT_fno_sycl_device_lib_EQ);
332- DAL.eraseArg (OPT_ftime_trace_EQ);
333- DAL.eraseArg (OPT_ftime_trace_granularity_EQ);
334- DAL.eraseArg (OPT_ftime_trace_verbose);
324+ // User args may contain options not intended for the frontend, but we can't
325+ // claim them here to tell the driver they're used later. Hence, suppress the
326+ // unused argument warning.
327+ DAL.AddFlagArg (nullptr , OptTable.getOption (OPT_Qunused_arguments));
335328
336329 ArgStringList ASL;
337330 for_each (DAL, [&DAL, &ASL](Arg *A) { A->render (DAL, ASL); });
331+ for_each (UserArgList,
332+ [&UserArgList, &ASL](Arg *A) { A->render (UserArgList, ASL); });
338333 transform (ASL, std::back_inserter (CommandLine),
339334 [](const char *AS) { return std::string{AS}; });
340335}
@@ -811,51 +806,21 @@ jit_compiler::parseUserArgs(View<const char *> UserArgs) {
811806 UserArgsRef[MissingArgIndex], MissingArgIndex);
812807 }
813808
814- // Check for unsupported options.
815- // TODO: There are probably more, e.g. requesting non-SPIR-V targets.
816- {
817- // -fsanitize=address
818- bool IsDeviceAsanEnabled = false ;
819- if (Arg *A = AL.getLastArg (OPT_fsanitize_EQ, OPT_fno_sanitize_EQ)) {
820- if (A->getOption ().matches (OPT_fsanitize_EQ) &&
821- A->getValues ().size () == 1 ) {
822- std::string SanitizeVal = A->getValue ();
823- IsDeviceAsanEnabled = SanitizeVal == " address" ;
824- }
825- } else {
826- // User can pass -fsanitize=address to device compiler via
827- // -Xsycl-target-frontend.
828- auto SyclFEArg = AL.getAllArgValues (OPT_Xsycl_frontend);
829- IsDeviceAsanEnabled = (std::count (SyclFEArg.begin (), SyclFEArg.end (),
830- " -fsanitize=address" ) > 0 );
831- if (!IsDeviceAsanEnabled) {
832- auto SyclFEArgEq = AL.getAllArgValues (OPT_Xsycl_frontend_EQ);
833- IsDeviceAsanEnabled =
834- (std::count (SyclFEArgEq.begin (), SyclFEArgEq.end (),
835- " -fsanitize=address" ) > 0 );
836- }
837-
838- // User can also enable asan for SYCL device via -Xarch_device option.
839- if (!IsDeviceAsanEnabled) {
840- auto DeviceArchVals = AL.getAllArgValues (OPT_Xarch_device);
841- for (auto DArchVal : DeviceArchVals) {
842- if (DArchVal.find (" -fsanitize=address" ) != std::string::npos) {
843- IsDeviceAsanEnabled = true ;
844- break ;
845- }
846- }
847- }
848- }
849-
850- if (IsDeviceAsanEnabled) {
851- return createStringError (
852- " Device ASAN is not supported for runtime compilation" );
853- }
854- }
855-
856- if (!AL.hasFlag (OPT_fsycl_device_code_split_esimd,
857- OPT_fno_sycl_device_code_split_esimd, true )) {
858- return createStringError (" ESIMD device code split cannot be deactivated" );
809+ // Check for options that are unsupported because they would interfere with
810+ // the in-memory pipeline.
811+ Arg *UnsupportedArg =
812+ AL.getLastArg (OPT_Action_Group, // Actions like -c or -S
813+ OPT_Link_Group, // Linker flags
814+ OPT_o, // Output file
815+ OPT_fsycl_targets_EQ, // AoT compilation
816+ OPT_fsycl_link_EQ, // SYCL linker
817+ OPT_fno_sycl_device_code_split_esimd, // invoke_simd
818+ OPT_fsanitize_EQ // Sanitizer
819+ );
820+ if (UnsupportedArg) {
821+ return createStringError (
822+ " Option '%s' is not supported for SYCL runtime compilation" ,
823+ UnsupportedArg->getAsString (AL).c_str ());
859824 }
860825
861826 return std::move (AL);
@@ -866,20 +831,14 @@ void jit_compiler::encodeBuildOptions(RTCBundleInfo &BundleInfo,
866831 std::string CompileOptions;
867832 raw_string_ostream COSOS{CompileOptions};
868833
869- for (Arg *A : UserArgList.getArgs ()) {
870- if (!(A->getOption ().matches (OPT_Xs) ||
871- A->getOption ().matches (OPT_Xs_separate))) {
872- continue ;
834+ for (Arg *A : UserArgList.filtered (OPT_Xs, OPT_Xs_separate)) {
835+ if (!CompileOptions.empty ()) {
836+ COSOS << ' ' ;
873837 }
874-
875- // Trim first and last quote if they exist, but no others.
876- StringRef AV{A->getValue ()};
877- AV = AV.trim ();
878- if (AV.front () == AV.back () && (AV.front () == ' \' ' || AV.front () == ' "' )) {
879- AV = AV.drop_front ().drop_back ();
838+ if (A->getOption ().matches (OPT_Xs)) {
839+ COSOS << ' -' ;
880840 }
881-
882- COSOS << (CompileOptions.empty () ? " " : " " ) << AV;
841+ COSOS << A->getValue ();
883842 }
884843
885844 if (!CompileOptions.empty ()) {
0 commit comments