func (t *target) makeABIHeaders() (err error) {
	abiDir := filepath.Join(IncludeDir, "abi")
	if err = os.Mkdir(abiDir, os.ModePerm); err != nil {
		return err
	}

	cc := os.Getenv("CC")
	if cc == "" {
		return errors.New("CC (compiler) env var not set")
	}

	// Build a sacrificial ELF file, to mine for C compiler behavior.
	binPath := filepath.Join(TempDir, "tmp_abi.o")
	bin, err := t.buildELF(cc, cCode, binPath)
	if err != nil {
		return fmt.Errorf("cannot build ELF to analyze: %v", err)
	}
	defer bin.Close()
	defer os.Remove(binPath)

	// Right now, we put everything in abi.h, but we may change this later.
	abiFile, err := os.Create(filepath.Join(abiDir, "abi.h"))
	if err != nil {
		return err
	}
	defer func() {
		if cerr := abiFile.Close(); cerr != nil && err == nil {
			err = cerr
		}
	}()

	if err = t.writeBitFieldMasks(bin, abiFile); err != nil {
		return fmt.Errorf("cannot write bitfield masks: %v", err)
	}

	return nil
}
// makeABIHeaders generates C header files based on the platform's calling convention.
// While many platforms have formal Application Binary Interfaces, in practice, whatever the
// dominant C compilers generate is the de-facto calling convention.
//
// We generate C headers instead of a Go file, so as to enable references to the ABI from Cgo.
makeABIHeaders generates C header files based on the platform's calling convention.
While many platforms have formal Application Binary Interfaces, in practice, whatever the
dominant C compilers generate is the de-facto calling convention.

We generate C headers instead of a Go file, so as to enable references to the ABI from Cgo.
// makeABIHeaders generates C header files based on the platform ' s calling convention . // While many platforms have formal Application Binary Interfaces in practice whatever the // dominant C compilers generate is the de - facto calling convention . // // We generate C headers instead of a Go file so as to enable references to the ABI from Cgo .
func (t *target) makeABIHeaders() (err error) {
	abiDir := filepath.Join(IncludeDir, "abi")
	if err = os.Mkdir(abiDir, os.ModePerm); err != nil {
		return err
	}
	cc := os.Getenv("CC")
	if cc == "" {
		return errors.New("CC (compiler) env var not set")
	}
	binPath := filepath.Join(TempDir, "tmp_abi.o")
	bin, err := t.buildELF(cc, cCode, binPath)
	if err != nil {
		return fmt.Errorf("cannot build ELF to analyze: %v", err)
	}
	defer bin.Close()
	defer os.Remove(binPath)
	abiFile, err := os.Create(filepath.Join(abiDir, "abi.h"))
	if err != nil {
		return err
	}
	defer func() {
		if cerr := abiFile.Close(); cerr != nil && err == nil {
			err = cerr
		}
	}()
	if err = t.writeBitFieldMasks(bin, abiFile); err != nil {
		return fmt.Errorf("cannot write bitfield masks: %v", err)
	}
	return nil
}
func ( t * target ) makeABIHeaders ( ) ( err error ) { abiDir := filepath . Join ( IncludeDir , " " ) if err = os . Mkdir ( abiDir , os . ModePerm ) ; err != nil { return err } cc := os . Getenv ( " " ) if cc == " " { return errors . New ( " " ) } binPath := filepath . Join ( TempDir , " " ) bin , err := t . buildELF ( cc , cCode , binPath ) if err != nil { return fmt . Errorf ( " " , err ) } defer bin . Close ( ) defer os . Remove ( binPath ) abiFile , err := os . Create ( filepath . Join ( abiDir , " " ) ) if err != nil { return err } defer func ( ) { if cerr := abiFile . Close ( ) ; cerr != nil && err == nil { err = cerr } } ( ) if err = t . writeBitFieldMasks ( bin , abiFile ) ; err != nil { return fmt . Errorf ( " " , err ) } return nil }
makeABIHeaders generates C header files based on the platform's calling convention.
makeABIHeaders generates C header files based on the platform ' s calling convention .
// Build a sacrificial ELF file, to mine for C compiler behavior. // Right now, we put everything in abi.h, but we may change this later.