The only difference between the tow functions is an additional line feed
after the comment. But it's enough to make the chunk unequal.
This is due to the debug information contained in the binary chunk.
Unfortunately, there is no public API for removing debug information.
If you can patch your version of Lua, just edit lapi.c and change
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
...
status = luaU_dump(L, getproto(o), writer, data, 0);
to
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int
strip) {
...
status = luaU_dump(L, getproto(o), writer, data, strip);
and call lua_dump with strip=1.