<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Vincent,<div><br></div><div>-rewrite-legacy-objc is out of date. For up to date support for ObjectiveC features and translation of its</div><div>modern ABI, you may want to look into -rewrite-objc. -rewrite-objc has simplified the workflow by pre-processing</div><div>user program and translating it into C++. -rewrite-legacy-objc requires user to do the pre-processing step manually.</div><div><br></div><div>- Fariborz</div><div><br><div><div>On Jul 28, 2013, at 1:22 PM, Vincent R. <<a href="mailto:forumer@smartmobili.com">forumer@smartmobili.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Le 28.07.2013 19:31, Vincent R. a écrit :<br><blockquote type="cite">Le 28.07.2013 15:44, Vincent R. a écrit :<br><blockquote type="cite">I have attached my latest patch(clang 3.3) below and I am wondering<br>if it wouldn't be easier to only modify the<br>RewriteObjc.cpp instead of trying to add a new rewriting option ...<br><br></blockquote></blockquote><br><br>Ok so last question, actually I have noticed a big difference between -rewrite-legacy-objc and -rewrite-objc because<br>when I try the two differents flags on the same file I get respectively a file of 40.8 kB and another of 392.4 kB.<br>The difference seems to be because when using -rewrite-objc flag the file is first preprocessed :<br><br>1) -rewrite-legacy-objc<br><br>clang -v -v -rewrite-legacy-objc NSButton.m -c -MMD -MP -DGNUSTEP_TARGET_DIR=\".\" -DGNUSTEP_TARGET_CPU=\"x86_64\" -DGNUSTEP_TARGET_OS=\"linux-gnu\" -DLIBRARY_COMBO=\"gnu-gnu-gnu\" -DBACKEND_BUNDLE=1 -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fobjc-nonfragile-abi -D_NONFRAGILE_ABI -pthread -fPIC -DDEBUG -fno-omit-frame-pointer -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -fgnu-runtime -Wall -fconstant-string-class=NSConstantString -I../Headers/Additions -I../Headers -I./. -I. -I/home/vincent/GNUstep/Library/Headers -I/GNUstep/Local/Library/Headers -I/GNUstep/System/Library/Headers -I/usr/include/libpng12<br>clang version 3.3 (186145)<br>Target: x86_64-unknown-linux-gnu<br>Thread model: posix<br><br>**** File is transformed (-rewrite-objc)<br><br>"/opt/bin/clang-3.3" -cc1 -triple x86_64-unknown-linux-gnu -rewrite-objc -disable-free -main-file-name NSButton.m -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -v -g -coverage-file /home/vincent/objc2cs/gnustep/core/gui/Source/NSButton.cpp -resource-dir /opt/bin/../lib/clang/3.3 -dependency-file NSButton.d -MT NSButton.o -MP -D "GNUSTEP_TARGET_DIR=\".\"" -D "GNUSTEP_TARGET_CPU=\"x86_64\"" -D "GNUSTEP_TARGET_OS=\"linux-gnu\"" -D "LIBRARY_COMBO=\"gnu-gnu-gnu\"" -D BACKEND_BUNDLE=1 -D GNUSTEP -D GNUSTEP_BASE_LIBRARY=1 -D GNU_GUI_LIBRARY=1 -D GNU_RUNTIME=1 -D GNUSTEP_BASE_LIBRARY=1 -D _NATIVE_OBJC_EXCEPTIONS -D _NONFRAGILE_ABI -D DEBUG -D GSWARN -D GSDIAGNOSE -I ../Headers/Additions -I ../Headers -I ./. -I . -I /home/vincent/GNUstep/Library/Headers -I /GNUstep/Local/Library/Headers -I /GNUstep/System/Library/Headers -I /usr/include/libpng12 -internal-isystem /usr/local/include -internal-isystem /opt/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wno-import -Wall -fdebug-compilation-dir /home/vincent/objc2cs/gnustep/core/gui/Source -fconstant-string-class NSConstantString -ferror-limit 19 -fmessage-length 232 -pthread -mstackrealign -fblocks -fobjc-runtime=gnustep-1.6 -fobjc-dispatch-method=non-legacy -fobjc-default-synthesize-properties -fno-objc-infer-related-result-type -fobjc-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o NSButton.cpp -x objective-c NSButton.m<br><br>2)-rewrite-objc<br><br>clang -v -v -rewrite-objc NSButton.m -c -MMD -MP -DGNUSTEP_TARGET_DIR=\".\" -DGNUSTEP_TARGET_CPU=\"x86_64\" -DGNUSTEP_TARGET_OS=\"linux-gnu\" -DLIBRARY_COMBO=\"gnu-gnu-gnu\" -DBACKEND_BUNDLE=1 -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -fobjc-nonfragile-abi -D_NONFRAGILE_ABI -pthread -fPIC -DDEBUG -fno-omit-frame-pointer -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -fgnu-runtime -Wall -fconstant-string-class=NSConstantString -I../Headers/Additions -I../Headers -I./. -I. -I/home/vincent/GNUstep/Library/Headers -I/GNUstep/Local/Library/Headers -I/GNUstep/System/Library/Headers -I/usr/include/libpng12<br><br>**** FIRST file is preprocessed(-E flag) :<br><br>"/opt/bin/clang-3.3" -cc1 -triple x86_64-unknown-linux-gnu -E -disable-free -main-file-name NSButton.m -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -v -g -coverage-file /tmp/NSButton-sxcmia.mi -resource-dir /opt/bin/../lib/clang/3.3 -dependency-file NSButton.d -MT NSButton.o -MP -D "GNUSTEP_TARGET_DIR=\".\"" -D "GNUSTEP_TARGET_CPU=\"x86_64\"" -D "GNUSTEP_TARGET_OS=\"linux-gnu\"" -D "LIBRARY_COMBO=\"gnu-gnu-gnu\"" -D BACKEND_BUNDLE=1 -D GNUSTEP -D GNUSTEP_BASE_LIBRARY=1 -D GNU_GUI_LIBRARY=1 -D GNU_RUNTIME=1 -D GNUSTEP_BASE_LIBRARY=1 -D _NATIVE_OBJC_EXCEPTIONS -D _NONFRAGILE_ABI -D DEBUG -D GSWARN -D GSDIAGNOSE -I ../Headers/Additions -I ../Headers -I ./. -I . -I /home/vincent/GNUstep/Library/Headers -I /GNUstep/Local/Library/Headers -I /GNUstep/System/Library/Headers -I /usr/include/libpng12 -internal-isystem /usr/local/include -internal-isystem /opt/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Wno-import -Wall -fdebug-compilation-dir /home/vincent/objc2cs/gnustep/core/gui/Source -fconstant-string-class NSConstantString -ferror-limit 19 -fmessage-length 232 -pthread -mstackrealign -fblocks -fobjc-runtime=gnustep-1.6 -fobjc-dispatch-method=non-legacy -fobjc-default-synthesize-properties -fobjc-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/NSButton-sxcmia.mi -x objective-c++-cpp-output NSButton.m<br><br>**** THEN file is transformed (-rewrite-objc)<br><br>"/opt/bin/clang-3.3" -cc1 -triple x86_64-unknown-linux-gnu -rewrite-objc -disable-free -main-file-name NSButton.m -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -v -g -coverage-file /home/vincent/objc2cs/gnustep/core/gui/Source/NSButton.cpp -resource-dir /opt/bin/../lib/clang/3.3 -Wall -Wno-import -Wall -fdebug-compilation-dir /home/vincent/objc2cs/gnustep/core/gui/Source -fconstant-string-class NSConstantString -ferror-limit 19 -fmessage-length 232 -pthread -mstackrealign -fblocks -fobjc-runtime=gnustep-1.6 -fobjc-dispatch-method=non-legacy -fobjc-default-synthesize-properties -fno-objc-infer-related-result-type -fobjc-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o NSButton.cpp -x objective-c++-cpp-output /tmp/NSButton-sxcmia.mi<br><br><br>Is is a normal behavior to have a difference in preprocessing between -rewrite-legacy-objc and -rewrite-objc or is it one of my change that could explain it ?<br>What part of code is responsible for that ?<br>With my new flag -rewrite-objc2cs I don't want to have a preprocessing stage but I don't know how to do it ?<br>If you have any pointers about this part, it would help a lot.<br><br>Pleas note that for the moment the RewriteObjC2Cs.cpp is a copy of RewriteObjC.cpp and I am calling a method called CreateObjC2CsRewriter<br>that actually corresponds to the CreateObjCRewriter (fragile runtime) of the RewriteObjC.cpp<br><br><br>ASTConsumer *RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI,<br>                                                 StringRef InFile) {<br> if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile, "cpp")) {<br>   if (CI.getLangOpts().ObjCRuntime.isNonFragile())<br>     return CreateModernObjCRewriter(InFile, OS,<br>                               CI.getDiagnostics(), CI.getLangOpts(),<br>                               CI.getDiagnosticOpts().NoRewriteMacros,<br>                               (CI.getCodeGenOpts().getDebugInfo() !=<br>                                CodeGenOptions::NoDebugInfo));<br>   return CreateObjCRewriter(InFile, OS,<br>                             CI.getDiagnostics(), CI.getLangOpts(),<br>                             CI.getDiagnosticOpts().NoRewriteMacros);<br> }<br> return 0;<br>}<br><br>ASTConsumer *RewriteObjC2CsAction::CreateASTConsumer(CompilerInstance &CI,<br>                                                 StringRef InFile) {<br> if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile, "cs")) {<br>  return CreateObjC2CsRewriter(InFile, OS,<br>                             CI.getDiagnostics(), CI.getLangOpts(),<br>                             CI.getDiagnosticOpts().NoRewriteMacros);<br> }<br> return 0;<br>}<br><br><br><br><br>Thanks<br><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></blockquote></div><br></div></body></html>