[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tools/ocaml/Makefile.rules: use correct C flags when compiling OCaml C stubs


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Wed, 25 Oct 2023 14:52:42 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edwin.torok@xxxxxxxxx>, "Christian Lindig" <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 25 Oct 2023 13:53:17 +0000
  • Ironport-data: A9a23:vK5nsaD02AmzTxVW/1Djw5YqxClBgxIJ4kV8jS/XYbTApD0k0jJWy mAcXzzSP6qKN2f1fI0gbI61pksG6pWBydAxQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48D8kk/nOH+KgYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMsMpvlDs15K6p4WtC4wRnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwp8tRJFl+3 9AkDDkoUACChuLswa2DY7w57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdIL2U3BPjDS0Qn1lM/BZ4gneHumn7ldD5wo1OJv6snpWPUyWSd1ZC0aoePIoDRFJU9ckCw/ jOX+H/COTojLcG54gLe90rzjcaXtHauMG4VPOLhraM76LGJ/UQDBRtTWValrP2Rjk+lR8kZO 0ES4jApr6U56AqsVNaVdxGxvnOspBMXXNtUVeog52ml1a788wufQG8eQVZ8hMcO7ZFsA2Zwj xnQwoKvWmQHXKCppWy1q5qyiAuCEwQpCWYnWz8FTAtf4sbbidRm5v7QdeqPAJJZn/WsR2Cgm WjW/Xlg71kApZRVjfnlpzgrlxrp9sCTEFNvjunCdjj9hj6VcrJJcGBBBbLzxvFaJYLRdUGbv X4LgKByB8hVVsnSzURhrAgXdYxFBspp0xWG2DaD57F7q1yQF4eLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNbSvzMvUtPtPqW5lCIU3c+TLNDK68gj1mO8UZSeN61Hs2OR74M57FyyDAbp3Ty b/EKJ3xXB72+IxszSasRvd17ILHMhsWnDuJLbiilkjP7FZrTCLNIVvzGAfUP79RAWLtiFm9z uuzwOPQlEwDDLeiPnKKmWPRRHhTRUUG6VnNg5Q/Xoa+zsBOQgnN19e5LWsdRrFY
  • Ironport-hdrordr: A9a23:r0IrP6OxT0tRPMBcTjejsMiBIKoaSvp037BK7S1MoNJuEvBw9v re+sjzsCWftN9/Yh4dcLy7VpVoBEmsl6KdgrNhWotKPjOW21dARbsKheffKn/bakjDH4Zmvp uIGJIObOEYY2IasS77ijPIbOrJwrO8gd6VbTG19QYdceloAZsQnzuQEmygYzRLrJEtP+tFKH KbjPA33waISDAsQemQIGIKZOTHr82jruObXfZXbyRXkzVnlFmTmcTHLyQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Edwin Török <edwin.torok@xxxxxxxxx>

The code currently uses GCC to compile OCaml C stubs directly,
and although in most cases this works, it is not entirely correct.

This will fail if the OCaml runtime has been recompiled to use and link with 
ASAN for example
(or other situations where a flag needs to be used consistently in everything 
that is linked into the same binary).

Use the OCaml compiler instead, which knows how to invoke the correct C 
compiler with the correct flags,
and append the Xen specific CFLAGS to that instead.

Drop the explicit -fPIC and -I$(ocamlc -where): these will now be provided by 
the compiler as needed.

Use -verbose so we see the actuall full C compiler command line invocation done 
by the OCaml compiler.

Signed-off-by: Edwin Török <edwin.torok@xxxxxxxxx>
---
 tools/ocaml/Makefile.rules | 2 +-
 tools/ocaml/common.make    | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/ocaml/Makefile.rules b/tools/ocaml/Makefile.rules
index 0d3c6ac839..74856e2282 100644
--- a/tools/ocaml/Makefile.rules
+++ b/tools/ocaml/Makefile.rules
@@ -37,7 +37,7 @@ ALL_OCAML_OBJS ?= $(OBJS)
        $(call quiet-command, $(OCAMLYACC) -q $<,MLYACC,$@)
 
 %.o: %.c
-       $(call quiet-command, $(CC) $(CFLAGS) -c -o $@ $<,CC,$@)
+       $(call quiet-command, $(OCAMLOPT) -verbose $(addprefix -ccopt 
,$(CFLAGS)) -c -o $@ $<,CC,$@)
 
 META: META.in
        sed 's/@VERSION@/$(VERSION)/g' < $< $o
diff --git a/tools/ocaml/common.make b/tools/ocaml/common.make
index 0c8a597d5b..629e4b3e66 100644
--- a/tools/ocaml/common.make
+++ b/tools/ocaml/common.make
@@ -9,8 +9,6 @@ OCAMLLEX ?= ocamllex
 OCAMLYACC ?= ocamlyacc
 OCAMLFIND ?= ocamlfind
 
-CFLAGS += -fPIC -I$(shell ocamlc -where)
-
 OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
 OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) 
-cc $(CC) -w F -warn-error F
 OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F
-- 
2.41.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.