这个我设置了全局环境变量:export PATH=$PATH:/Applications/xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/
都不行。这个该怎么一劳永逸设置。
这个我设置了全局环境变量:export PATH=$PATH:/Applications/xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.1.sdk/System/Library/Frameworks/
都不行。这个该怎么一劳永逸设置。
你可以用alias呀hhh
alias clang=“clang -framework Foundation”
应该这个吧。
虽然这个似乎有点傻
clang找isysroot和framework用的是PATH?
学到了
这个我刚看,真不懂还。见笑了张总。那该怎么设置。。。
clang参数里加个 -isysroot 啥啥啥再-framework啥的才行应该
这样子只能一个framework一个framework的加,不能批量加载。
建个Xcode工程,编译,然后把命令拷出来
这里面先有一个临时环境变量的设置?
然后使用-isysroot加载了系统sdk的路径。
其他就是一些参数了。。。
但是我在用命令行clang 预编译的时候使用-isysroot是ok的,但是到了词法分析生成token的时候就报错了
虽然报了很多找不到头文件的错误,但是最后貌似生成的Tokens也是正常的。。。不知道这些error有没有影响
预处理完成后就会进行词法分析,这里会把代码切成一个个 Token,比如大小括号,等于号还有字符串等。
clang -fmodules -fsyntax-only -Xclang -dump-tokens main.m
然后是语法分析,验证语法是否正确,然后将所有节点组成抽象语法树 AST 。
clang -fmodules -fsyntax-only -Xclang -ast-dump main.m
完成这些步骤后就可以开始IR中间代码的生成了,CodeGen 会负责将语法树自顶向下遍历逐步翻译成 LLVM IR,IR 是编译过程的前端的输出后端的输入。
clang -S -fobjc-arc -emit-llvm main.m -o main.ll
这三条命令我就没顺利执行完。。。。hhhh
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu11 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/tomyang/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/tomyang/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=8.1 -g -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wunguarded-availability -fembed-bitcode-marker -index-store-path /Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Index/DataStore -iquote /Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/dsfsdafsafd-generated-files.hmap -I/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/dsfsdafsafd-own-target-headers.hmap -I/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/dsfsdafsafd-all-target-headers.hmap -iquote /Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/dsfsdafsafd-project-headers.hmap -I/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Products/Debug-iphoneos/include -I/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/DerivedSources/arm64 -I/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/DerivedSources -F/Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Products/Debug-iphoneos -MMD -MT dependencies -MF /Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/Objects-normal/arm64/main.d --serialize-diagnostics /Users/tomyang/Library/Developer/Xcode/DerivedData/dsfsdafsafd-ccbfakvqpivdvecyiymzyjxaqlgh/Build/Intermediates.noindex/dsfsdafsafd.build/Debug-iphoneos/dsfsdafsafd.build/Objects-normal/arm64/main.dia -S -fobjc-arc -emit-llvm -c main.m -o main.ll
我用了这么长的命令 终于可以了。。。。。。。。。。
太强了,膜
这个是给编译环境clang用的吧。
这一大堆参数跟你都没关系。为了dump ir的话sysroot和头文件导入路径之类的就可以了
只是为了玩llvm的话不用执着生成iOS的AST/IR,macOS也一样还能少打一大堆命令
其实最后发现原因是我没有装toolchains, 执行一些xcode-select -install 就ok了。
但是张总我发现各问题,就是我用ninja编译出来的clang再执行 clang -S -emit-llvm main.m -o main.ll
命令时会出现
这个错误。找了好久原因,然后对比了以下xcode的编译命令,最后发现原因是:我用的clang时ninja的clang,而xcode用的clang是/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
用xcode的clang执行上述命令就OK的,自己ninja的clang命令就不行(debug 模式)。
请问张总,这个有什么区别吗