vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

adding tcc support #73

Open norayr opened 4 years ago

norayr commented 4 years ago

hello, @dcwbrown

I have added initial support for tcc compiler. I did it mostly because I have a request to add it by the company, which has to use only tcc compiler for one important project. Also, tcc seems to be a fairly good compiler (I checked it back 10 years ago, and it wasn't stable enough, as I remember) nowadays, fairly fast, much faster than gcc/clanng, and generates slimmer binaries.

Please review my changes in dedicated tcc_support branch: https://github.com/vishaps/voc/commit/a35668bf93b8550559be7e7a45d759d68db87b44 https://github.com/vishaps/voc/commit/9626a95daa47fd73bdf24ba9891f1af32ac21ccf

I had to add:

I also had to update bootstrap sources.

I only have linux/x86_64, and cannot test the changes now on other Unix systems. Also, tcc is available for Windows, so I am looking forward for your suggestions on how to integrate tcc related changes in to the mainline voc source.

dcwbrown commented 4 years ago

Hi Norayr,

Nice to be supporting a small and simple(r) C compiler.

I've added comments to your commit - there's a better, simpler way to disable static linking for tcc, but otherwise looks good. I've never given comments on github before, so please let me know whether you see them OK.

I will look into getting all my build machines running again. At least some of them should be easy ... I hope.

And I'm hoping the removal of the space after -l won't be an issue.

Re tcc on windows - I've no idea what would be required, maybe it would just work, maybe it would be a lot of trouble. Is it important?

Cheers -- Dave.

On 2019-10-10 15:01, Norayr Chilingarian wrote:

hello, @dcwbrown [1]

I have added initial support for tcc compiler. I did it mostly because I have a request to add it by the company, which has to use only tcc compiler for one important project. Also, tcc seems to be a fairly good compiler (I checked it back 10 years ago, and it wasn't stable enough, as I remember) nowadays, fairly fast, much faster than gcc/clanng, and generates slimmer binaries.

Please review my changes in dedicated tcc_support branch: a35668b [2] 9626a95 [3]

I had to add:

elif defined(TINYC) case in src/tools/make/configure.c

ifeq condition for tcc compiler in src/tools/make/oberon.mk (though tcc seems to support -static flag, it was not able to combine object files into one executable while using that flag).

I had to change the line snprintf(libspec, sizeof(libspec), " -l%s", oname); where I removed whitespace between -l and %s because otherwise tcc was failing.

I also had to update bootstrap sources.

I only have linux/x86_64, and cannot test the changes now on other Unix systems. Also, tcc is available for Windows, so I am looking forward for your suggestions on how to integrate tcc related changes in to the mainline voc source.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [4], or unsubscribe [5].

Links:

[1] https://github.com/dcwbrown [2] https://github.com/vishaps/voc/commit/a35668bf93b8550559be7e7a45d759d68db87b44 [3] https://github.com/vishaps/voc/commit/9626a95daa47fd73bdf24ba9891f1af32ac21ccf [4] https://github.com/vishaps/voc/issues/73?email_source=notifications&email_token=AAYKDIEQIS7GVC4T7H2KP73QN4YUFA5CNFSM4I7NLYJKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQ6E7KA [5] https://github.com/notifications/unsubscribe-auth/AAYKDIHFEBG7UNOD6UQAIY3QN4YUFANCNFSM4I7NLYJA

antranigv commented 4 years ago

Greetings all

David, would you mind if I setup the build infrastructure?

I’m thinking about using BuildBot and generate artifacts and serve them from my home server.

However, if you agree, I might need your help to setup agents on non-intel devices :)

Let me know.

Sent from my iPhone

On Oct 10, 2019, at 9:25 PM, David C W Brown notifications@github.com wrote:

Hi Norayr,

Nice to be supporting a small and simple(r) C compiler.

I've added comments to your commit - there's a better, simpler way to disable static linking for tcc, but otherwise looks good. I've never given comments on github before, so please let me know whether you see them OK.

I will look into getting all my build machines running again. At least some of them should be easy ... I hope.

And I'm hoping the removal of the space after -l won't be an issue.

Re tcc on windows - I've no idea what would be required, maybe it would just work, maybe it would be a lot of trouble. Is it important?

Cheers -- Dave.

On 2019-10-10 15:01, Norayr Chilingarian wrote:

hello, @dcwbrown [1]

I have added initial support for tcc compiler. I did it mostly because I have a request to add it by the company, which has to use only tcc compiler for one important project. Also, tcc seems to be a fairly good compiler (I checked it back 10 years ago, and it wasn't stable enough, as I remember) nowadays, fairly fast, much faster than gcc/clanng, and generates slimmer binaries.

Please review my changes in dedicated tcc_support branch: a35668b [2] 9626a95 [3]

I had to add:

elif defined(TINYC) case in src/tools/make/configure.c

ifeq condition for tcc compiler in src/tools/make/oberon.mk (though tcc seems to support -static flag, it was not able to combine object files into one executable while using that flag).

I had to change the line snprintf(libspec, sizeof(libspec), " -l%s", oname); where I removed whitespace between -l and %s because otherwise tcc was failing.

I also had to update bootstrap sources.

I only have linux/x86_64, and cannot test the changes now on other Unix systems. Also, tcc is available for Windows, so I am looking forward for your suggestions on how to integrate tcc related changes in to the mainline voc source.

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [4], or unsubscribe [5].

Links:

[1] https://github.com/dcwbrown [2] https://github.com/vishaps/voc/commit/a35668bf93b8550559be7e7a45d759d68db87b44 [3] https://github.com/vishaps/voc/commit/9626a95daa47fd73bdf24ba9891f1af32ac21ccf [4] https://github.com/vishaps/voc/issues/73?email_source=notifications&email_token=AAYKDIEQIS7GVC4T7H2KP73QN4YUFA5CNFSM4I7NLYJKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQ6E7KA [5] https://github.com/notifications/unsubscribe-auth/AAYKDIHFEBG7UNOD6UQAIY3QN4YUFANCNFSM4I7NLYJA — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

dcwbrown commented 4 years ago

I have finished making my build server work again. It's building all except the android platform (there is no problem but I need to stop for today).

It should be responding to github checkin hooks though I haven't tested this.

I added a feature for manually triggering builds: If you open webpage

https://brownsmeet.com/githubhook/vishaps-trigger/tcc_support

-- you will trigger a new build of the branch named at the end of the url.

The build status is updated dynamically on the github/visshaps/voc readme, or you can view

https://brownsmeet.com/githubhook/vishaps-status.svg

Note that if you click on any line in the status you will be shown the build log for that particular build. This even works during the build so you can see how far it has got.


With regard to BuildBot - I'm afraid I'm out of my depth there. I've no idea how much it can do.

You are very welcome to have a go :-).

Can it build with mingw, or MSVC, or on android? Can it parse logs and show status of test parts?

Good luck! I think you may have big job on your hands ...

norayr commented 4 years ago

thank you all, yes, I have noticed your comment, but probably would not notice if you didn't mention it. tomorrow will try as you've pointed out.

also, i am afraid, building software with -M (link statically) won't work. will try tomorrow.

norayr commented 4 years ago

So, I have updated the branch, and it is ready to be merged with master. I have checked, -M flag doesn't cause crashes, just the static linking of output binaries does not take place. So, well, may be that's ok.

I think Readme also should be updated. It should also point out that tcc is only supported on Unix systems (for now).

About Windows, it only passed somewhere on the web, that for linking to Windows libraries tcc needs some .def files, and headers alone are not enough.

dcwbrown commented 4 years ago

Looks good - all the existing tests passed. You're fine to do the merge.

Re comment - I'll update doc/compiler.md once you've merged. And maybe I will get around to updating the compiler help display to indicate which link types it supports depending on how it has been built, perhaps.

I'm not planning to do the work to make tcc work on windows and document it.

-- Dave.

norayr commented 4 years ago

merged to master.

norayr commented 4 years ago

also, there is no test currently for tcc on the main page.

dcwbrown commented 4 years ago

It will need creating ...

I can do so if you wish - for a couple of architectures.

Which of centos, freebsd, fedora, ubuntu, opensuse would you most want to test?

norayr commented 4 years ago

i don't know, don't want to cause you unnecessary/extra work.

if or when you find mood to do so, i think ubuntu or fedora are okay, because they have more recent tcc, and if anything changes, it will be noticeable on those platforms? so just pick one of those. and may be freebsd as well.

and thank you.

dcwbrown commented 4 years ago

On Ubuntu tcc went smoothly. The latest tcc is easily installed with apt install tcc.

On Fedora (29 or 30) the tcc compiler itself segfaults.

There are some messages about it on the tcc mailing list, but no resolution.

Did you try on Fedora, and if you solved this, how did you do it?

Now trying freebsd.

-- Dave.

dcwbrown commented 4 years ago

Also getting segfault in tcc on freebsd.

norayr commented 4 years ago

hmmm. No, I only have gentoo (or funtoo) or all my computers. But I have CentOS in the vicinity, and Debian, I will try on them.

I guess, I did not do a research yet, I guess, this might be about stack protection. Or something like address space randomization, some modern security feature related to address space.