rebuild.sh: Fix Linux build. The previous patch broke the Linux build. The main reason was that the definition of GLIB_CFLAGS/GLIB_LIBS which were exported when building the linux-x86 binaries, were later picked by the linux-x86_64 build incorrectly. The fix ensures that the environment variables are undefined. Also save the environment to $BUILD_DIR/environment.txt to better diagnose problems in the future.