Building an application should always be done on a server that you trust, you are in control of and has the latest security patches and hardening configured. In some applications you can use security techniques and modules that can protect your application from known security issues. Always use these techniques when they are available.
Ensure that build processes for system level languages have all security flags enabled, such as ASLR, DEP, and other security checks specific for your application need.