Using the C compiler from the Go toolchain

37 views
Skip to first unread message

Lucio De Re

unread,
Jun 2, 2014, 7:46:32 AM6/2/14
to go-p...@googlegroups.com
My objective is to access the OpenLDAP libraries from Go on a native Plan 9 platform.  This may be daft, but it short-circuits a lot of development I don't have the time (or the inclination) for.

So, code that originally compiled successfully using native 8c is now shoehorned into the Go's 8c and, after quite a bit of bending the command line flags, I've made a bit of progress: one seemingly successful compilation.

What I needed to do, though, was recompile cmd/cc/lex.c because it attempts to exec CPP which it defines as "cpp".  Without the /bin/ prefix, this did not work.

Adding the /bin/ prefix sufficed to compile successfully, but now I was wondering what the least intrusive way might be to make this change permanent.  As it was, I just changed the target string, which I'm sure is pretty unfriendly to other platforms.

I note the use of _WIN32 to discriminate for Windows in the same module, so my first thought was to add an

#ifdef _PLAN9
#define CPP "/bin/cpp"
#else
#define CPP "cpp"
#endif

but I also noted that there is a

#ifndef CPP
#define CPP "cpp"
#endif

so I wonder whether we can set CPP externally in a platform-dependent way to address this problem.

Suggestions are sought.

Lucio.

Reply all
Reply to author
Forward
0 new messages