【问题标题】:How to pass -S flag to ocamlopt with ocamlbuild?如何使用 ocamlbuild 将 -S 标志传递给 ocamlopt?
【发布时间】:2014-12-06 15:29:52
【问题描述】:

在使用 ocamlbuild 和 corebuild 命令进行构建时,我想将 -S 标志传递给 ocamlopt。

我知道 ocamlbuild -cflag -S ... 不会起作用,因为 -S 标志只存在于 ocamlopt 而不是 ocamlc。

如何使用 _tags 文件执行此操作?

【问题讨论】:

    标签: ocaml ocamlbuild


    【解决方案1】:

    这是使用 myocamlbuild.ml_tags 的一种方法。

    myocamlbuild.ml 中,添加 flag 指令让 ocamlbuild 识别一个新标签 - 这里是 keep_asm - 这将在编译时为选定的文件启用 -S本地

    flag ["ocaml";"compile";"native";"keep_asm"] (S [A "-S"]);
    

    如果列表中没有"native" 字符串传递给flag,则该标志将在使用ocaml 的任何编译 阶段启用(如字符串@ 所示) 987654326@ 和 "compile"),并且会在调用 ocamlc 时触发,这是您不想要的。

    因此,对于仅执行上述操作的完整独立 myocamlbuild.ml,结果如下:

    open Ocamlbuild_plugin;;
    open Command;;
    
    dispatch begin function
      | Before_rules -> 
        begin
        end
      | After_rules ->
        begin
          flag ["ocaml";"compile";"native";"keep_asm"] (S [ A "-S"]);
        end
      | _ -> ()
    end
    

    一旦定义了新标签,您就可以在 _tags 文件中使用它,就像使用任何其他标签一样,例如:

    <myfile.ml>: use_bigarray, keep_asm 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-25
      • 1970-01-01
      • 2016-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-28
      相关资源
      最近更新 更多